After testing the program my run did not produce the results that you describe. Turn out that my path to the ".exe" file fell apart when there spaces in the path that made a mess of things.
As I thought "*agrv" is the same as "*argv[0]", i.e., the path and file name of the program running.
Remove the "system" call and your program would only run once.
Depending on how you run your program you might need something to pause the program to keep the window open before it finishes.
Ah, I hadn't even considered what might happen if there were spaces in the path. Good catch, thanks! I'm running it under cygwin and didn't have any spaces.
I knew it would be executing itself, but what I can't figure out is why the usual method of dealing with these things doesn't seem to work.
kill `ps | grep recursive | cut -c 1-10`
I'm thinking maybe "system" itself takes a while to get started (a very long time compared to this tiny program?) and whatever it ends up doing doesn't show in the process list until then .. so there would always be a call to "system" struggling to start that wasn't yet listed to be killed, but once it was listed, it almost immediately started another call to system? It didn't run fast enough to bring down the machine or even exhaust the memory, so something was taking a long time to happen.
What's it doing, and why isn't the call to system listed as something else in the process table while it's doing it?
system() is a synchronous function. Generally it won't return until the child process has terminated. I'd expect your program will create new processes that can never terminate normally, until the very very latest one is killed or the system runs out of memory.
You're saying that you're looking at the process list in the system monitor and you're not seeing thousands of hanged processes?
only dozens to hundreds. or if I typed ps right after running the command mentioned above, only a few. Almost as if it was firing up an entire shell just to execute the command (which, I suppose it is..) but none of the processes I would associate with another shell instance are listed, so there's no intermediate (for example, "bash" or system or whatever) to target with the kill command to get that very last process you mentioned.
It doesn't show up in the process table until it's too late. That's what's weird.