digitalmars.D.learn - Infinite loop not working DMD2
- Guillermo Estrada (15/15) Jun 02 2011 Hi, been developing in D a lot but first time in news groups, I
- Brad Roberts (2/21) Jun 02 2011 The exec* family of functions cause the new app to replace the current p...
- Guillermo Estrada (2/3) Jun 02 2011 current process. So after the execv, the loop doesn't exist.
- =?UTF-8?B?QWxpIMOHZWhyZWxp?= (3/6) Jun 02 2011 Would std.process.system or std.process.shell work?
- Guillermo Estrada (8/15) Jun 02 2011 Well, std.process.system does not wok as intended because if you
- Jonathan M Davis (18/37) Jun 02 2011 Okay. I just glanced at std.process, and I'd suggest trying spawnvp. It ...
- Guillermo Estrada (23/58) Jun 02 2011 exist.
- Guillermo Estrada (6/10) Jun 02 2011 As expected spawnvp() creates child process that exit with the father,
- Jonathan M Davis (15/23) Jun 02 2011 If they were called in spawned threads. What he really wants is fork tho...
- Steven Schveighoffer (9/24) Jun 02 2011 std.process is woefully unmaintained. Lars K is developing a new versio...
- Guillermo Estrada (8/15) Jun 02 2011 process,
Hi, been developing in D a lot but first time in news groups, I thought this might be the place. I'm trying to make a fork bomb in D (of course no fork cause target its windows platform) but anyway. I did one a while ago using D1 and Tango and all ran perfectly, I'm trying to migrate my whole dev to D2 and Phobos (reading Andrei's book) but this one does not work. import std.process; void main(string[] args) { while( true ) { execv(args[0], null); } } It spawns one after the other but just once, it always exits the father process, if u comment the execv line, program stays in the infinite loop as expected. any insight?
Jun 02 2011
On 6/2/2011 8:43 AM, Guillermo Estrada wrote:Hi, been developing in D a lot but first time in news groups, I thought this might be the place. I'm trying to make a fork bomb in D (of course no fork cause target its windows platform) but anyway. I did one a while ago using D1 and Tango and all ran perfectly, I'm trying to migrate my whole dev to D2 and Phobos (reading Andrei's book) but this one does not work. import std.process; void main(string[] args) { while( true ) { execv(args[0], null); } } It spawns one after the other but just once, it always exits the father process, if u comment the execv line, program stays in the infinite loop as expected. any insight?The exec* family of functions cause the new app to replace the current process. So after the execv, the loop doesn't exist.
Jun 02 2011
The exec* family of functions cause the new app to replace thecurrent process. So after the execv, the loop doesn't exist. Any way to spawn the process without killing himself?
Jun 02 2011
On 06/02/2011 08:51 AM, Guillermo Estrada wrote:Would std.process.system or std.process.shell work? AliThe exec* family of functions cause the new app to replace thecurrent process. So after the execv, the loop doesn't exist. Any way to spawn the process without killing himself?
Jun 02 2011
== Quote from Ali Çehreli (acehreli yahoo.com)'s articleOn 06/02/2011 08:51 AM, Guillermo Estrada wrote:Well, std.process.system does not wok as intended because if you kill the parent process all children die. std.process.shell works and does what it should but spawning a cmd on each request, for a dirty quick fork bomb well, it's the same, but there should be a way in phobos to spawn process and detach them or even have control over them and close them like in tango.sys.Process, without having to go to the std.c.* libs. Thnx for the help :DWould std.process.system or std.process.shell work? AliThe exec* family of functions cause the new app to replace thecurrent process. So after the execv, the loop doesn't exist. Any way to spawn the process without killing himself?
Jun 02 2011
On 2011-06-02 09:14, Guillermo Estrada wrote:=3D=3D Quote from Ali =C7ehreli (acehreli yahoo.com)'s article =20Okay. I just glanced at std.process, and I'd suggest trying spawnvp. It loo= ks=20 like it ends up calling fork, so it'll probably work. I haven't tried it=20 though and don't know anything about the function beyond what's in the code. Also, just because there _should_ be a way for there to do something in=20 druntime or Phobos doesn't mean that there _is_ a way. There's plenty that = you=20 still have to call C functions for, if nothing else because it takes time t= o=20 add all of the relevant features, and not all of the relevant features are= =20 always remembered by the Phobos developers. So, if you can't find something= =20 that really seems like it should be in Phobos, open an enhancement request = on=20 it on bugzilla: d.puremagic.com/issues/ =2D Jonathan M DavisOn 06/02/2011 08:51 AM, Guillermo Estrada wrote:=20 Well, std.process.system does not wok as intended because if you kill the parent process all children die. std.process.shell works and does what it should but spawning a cmd on each request, for a dirty quick fork bomb well, it's the same, but there should be a way in phobos to spawn process and detach them or even have control over them and close them like in tango.sys.Process, without having to go to the std.c.* libs. Thnx for the help :D=20 Would std.process.system or std.process.shell work? AliThe exec* family of functions cause the new app to replace the=20 current process. So after the execv, the loop doesn't exist. =20 Any way to spawn the process without killing himself?
Jun 02 2011
== Quote from Jonathan M Davis (jmdavisProg gmx.com)'s articleOn 2011-06-02 09:14, Guillermo Estrada wrote:the== Quote from Ali Çehreli (acehreli yahoo.com)'s articleOn 06/02/2011 08:51 AM, Guillermo Estrada wrote:The exec* family of functions cause the new app to replaceexist.current process. So after the execv, the loop doesn'tworksWell, std.process.system does not wok as intended because if you kill the parent process all children die. std.process.shellAny way to spawn the process without killing himself?Would std.process.system or std.process.shell work? Aliaand does what it should but spawning a cmd on each request, forwaydirty quick fork bomb well, it's the same, but there should be aoverin phobos to spawn process and detach them or even have controlgothem and close them like in tango.sys.Process, without having tospawnvp. It looto the std.c.* libs. Thnx for the help :DOkay. I just glanced at std.process, and I'd suggest tryingks like it ends up calling fork, so it'll probably work. I haven'ttried itthough and don't know anything about the function beyond what's inthe code.Also, just because there _should_ be a way for there to dosomething indruntime or Phobos doesn't mean that there _is_ a way. There'splenty thatyou still have to call C functions for, if nothing else because ittakes time to add all of the relevant features, and not all of the relevantfeatures arealways remembered by the Phobos developers. So, if you can't findsomethingthat really seems like it should be in Phobos, open an enhancementrequeston it on bugzilla: d.puremagic.com/issues/ - Jonathan M DavisJohnathan, just yesterday I was at github checking exactly the same thing, spawnvp() is not documented and still on development, but it seems it just call the underlying std.c.process.spawnvp function, either way, spawnvp in either P_NOWAIT or P_NOWAITO modes will spawn child process... so killing the father is the case of calling system(args[]) but I'll have to test it. Thnx for the ideas.
Jun 02 2011
So, if you can't find something that really seems like it should be in Phobos, open an enhancement request on it on bugzilla: d.puremagic.com/issues/ Jonathan M DavisAs expected spawnvp() creates child process that exit with the father, just as system(). exec*() replaces the parent process, the only one I can use is shell() that actually opens a cmd with the process (detached) and expects the output, so in any other use shell() is not a viable option. Gonna keep trying, and I will create an enhacement request as you propose, Thnx.
Jun 02 2011
On 2011-06-02 08:59, Ali =C7ehreli wrote:On 06/02/2011 08:51 AM, Guillermo Estrada wrote:If they were called in spawned threads. What he really wants is fork though= , I=20 believe (it _is_ a _fork_ bomb after all), but I'm not sure how safe that i= s=20 or isn't to call in D, since I don't know how that affects the state of the= =20 druntime. It's probably okay, since you then have two, completely separate= =20 processes, but I don't know. Regardless, you'd have to be calling the C for= k,=20 because I don't believe that druntime or Phobos provide any kind of wrapper= =20 for fork. =2D Jonathan M Davis=20 Would std.process.system or std.process.shell work?The exec* family of functions cause the new app to replace the=20 current process. So after the execv, the loop doesn't exist. =20 Any way to spawn the process without killing himself?
Jun 02 2011
On Thu, 02 Jun 2011 11:43:50 -0400, Guillermo Estrada <phrzn live.com> wrote:Hi, been developing in D a lot but first time in news groups, I thought this might be the place. I'm trying to make a fork bomb in D (of course no fork cause target its windows platform) but anyway. I did one a while ago using D1 and Tango and all ran perfectly, I'm trying to migrate my whole dev to D2 and Phobos (reading Andrei's book) but this one does not work. import std.process; void main(string[] args) { while( true ) { execv(args[0], null); } } It spawns one after the other but just once, it always exits the father process, if u comment the execv line, program stays in the infinite loop as expected. any insight?std.process is woefully unmaintained. Lars K is developing a new version, and I am really really late getting a windows version to him so it can be included in phobos. It includes simple methods to create a sub-process, which should solve your issue. I think this shall be my next "Spare time" project for D. Sorry about this, Lars. -Steve
Jun 02 2011
std.process is woefully unmaintained. Lars K is developing a newversion,and I am really really late getting a windows version to him so itcan beincluded in phobos. It includes simple methods to create a sub-process,which should solve your issue. I think this shall be my next "Spare time" project for D. Sorryaboutthis, Lars. -SteveWell Steve I hope to see it soon, I love D and I just hope GSoC helps it a LOT, for me I'm just going to make some updated bindings to work with D2 now that I'm migrating to it. Thnx for the reply.
Jun 02 2011