The script is running on the PC.
Once I launch the "system("Doing something take a long time");" from
my perl script(doit.pl), I hope when the user kill my doit.pl, it will
kill the
"system("Doing something take a long time");" process as well, I
really don't want leave the process behind.
Is that anywhere I can find code example doing such thing?
Thanks a lot,
Mav
lee <> wrote in message news:<>...
> Mav wrote:
>
> > I am trying to lanuch a command on my perl script using system call,
> > I wonder is that a way when someone hit Ctrl-Y, it will kill my
> > script,and also kill that system call process as well.
>
> Yes.
>
> When you launch the process, note its process ID.
>
> Then have your script "trap" the control character in question,
> and when that character is received, call the system 'kill'
> command
> on the previously noted PID, as described by someone else on
> this thread.
>
> See, for example, perldoc -q signal:
>
> Found in .... pod/perlfaq8 :
> How do I trap control characters/signals?
>
> $Interrupted = 0; # to ensure it has a value
> $SIG{INT} = sub {
> $Interrupted++;
> syswrite(STDERR, "ouch\n", 5);
> }
>
>
> Lee Goddard
|