digitalmars.D.learn - Infinite loop not working DMD2
- Guillermo Estrada <phrzn live.com> Jun 02 2011
- Brad Roberts <braddr puremagic.com> Jun 02 2011
- Guillermo Estrada <phrzn live.com> Jun 02 2011
- =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> Jun 02 2011
- Guillermo Estrada <phrzn live.com> Jun 02 2011
- Guillermo Estrada <phrzn live.com> Jun 02 2011
- Guillermo Estrada <phrzn lve.com> Jun 02 2011
- Jonathan M Davis <jmdavisProg gmx.com> Jun 02 2011
- Jonathan M Davis <jmdavisProg gmx.com> Jun 02 2011
- "Steven Schveighoffer" <schveiguy yahoo.com> Jun 02 2011
- Guillermo Estrada <phrzn live.com> Jun 02 2011
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 the
Any way to spawn the process without killing himself?
Jun 02 2011
On 06/02/2011 08:51 AM, Guillermo Estrada wrote:The exec* family of functions cause the new app to replace the
Any way to spawn the process without killing himself?
Would std.process.system or std.process.shell work? Ali
Jun 02 2011
== 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 replace the
Any way to spawn the process without killing himself?
Ali
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
Jun 02 2011
== Quote from Jonathan M Davis (jmdavisProg gmx.com)'s articleOn 2011-06-02 09:14, Guillermo Estrada wrote:== 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 replace
current process. So after the execv, the loop doesn't
Any way to spawn the process without killing himself?
Would std.process.system or std.process.shell work? Ali
Well, std.process.system does not wok as intended because if you kill the parent process all children die. std.process.shell
and does what it should but spawning a cmd on each request, for
dirty quick fork bomb well, it's the same, but there should be a
in phobos to spawn process and detach them or even have control
them and close them like in tango.sys.Process, without having to
to the std.c.* libs. Thnx for the help :D
ks like it ends up calling fork, so it'll probably work. I haven't
though and don't know anything about the function beyond what's in
Also, just because there _should_ be a way for there to do
druntime or Phobos doesn't mean that there _is_ a way. There's
you still have to call C functions for, if nothing else because it
o add all of the relevant features, and not all of the relevant
always remembered by the Phobos developers. So, if you can't find
that really seems like it should be in Phobos, open an enhancement
on it on bugzilla: d.puremagic.com/issues/ - Jonathan M Davis
Johnathan, 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 Davis
As 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 09:14, Guillermo Estrada wrote:=3D=3D Quote from Ali =C7ehreli (acehreli yahoo.com)'s article =20On 06/02/2011 08:51 AM, Guillermo Estrada wrote:The exec* family of functions cause the new app to replace the
current process. So after the execv, the loop doesn't exist. =20 Any way to spawn the process without killing himself?
Would std.process.system or std.process.shell work? Ali
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
Okay. 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 Davis
Jun 02 2011
On 2011-06-02 08:59, Ali =C7ehreli wrote:On 06/02/2011 08:51 AM, Guillermo Estrada wrote:The exec* family of functions cause the new app to replace the
current process. So after the execv, the loop doesn't exist. =20 Any way to spawn the process without killing himself?
Would std.process.system or std.process.shell work?
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
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 new
and I am really really late getting a windows version to him so it
included in phobos. It includes simple methods to create a sub-
which should solve your issue. I think this shall be my next "Spare time" project for D. Sorry
this, Lars. -Steve
Well 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









Guillermo Estrada <phrzn lve.com> 