in reply to Re: How to kill forked process
in thread How to kill forked process

I think I goofed in my problem description, I didn't know what fork() was, I thought it was a general term to spawn a completely different program, not duplicate itself.

In fact the system() command might work for me if I am able to interrupt it. I just want to spawn a system process but be able to kill it upon an interrupt signal from the user.

Sorry for my ignorance. And thanks for your reply.

Replies are listed 'Best First'.
Re^3: How to kill forked process
by zentara (Cardinal) on Feb 17, 2005 at 14:21 UTC
    You can just use the control-c(SIG-INT) to interrupt the current system, and move to the next in the list. Try:
    #!/usr/bin/perl $rc = system('top'); $rc = system('date; sleep 10'); $rc = system('top'); $rc = system('date; sleep 10'); $rc = system('top');

    I'm not really a human, but I play one on earth. flash japh