W
Weirong Zhu
On linux
1. I have a perl script, the main body of which is a for loop. In each
iteration the script use "system" to call outside exe to do some work.
The whole script may run very long time. Sometimes, I want to use
Ctrl+C to terminate the script. However, when I use ctrl+c, I can only
terminate the child process invoked by system, the script itself is
still running. Then I have to open another term to kill the script by
its pid.
I want to know how can I kill the script process by ctrl+c directly in
this conditon. Please aware that I can not use the return value of
system to do this. Because even the return value of system means a
error, the script just think this iteration failed, it will continue
the next iteration.
2. It seems change the $ENV{"xxx"} only takes effect in child process.
How can I set the enviroment variable in the middle of a perl script?
For example, I want to change the $LANG several times, so that I can
print different language's time format by using "localtime"
Thanks
1. I have a perl script, the main body of which is a for loop. In each
iteration the script use "system" to call outside exe to do some work.
The whole script may run very long time. Sometimes, I want to use
Ctrl+C to terminate the script. However, when I use ctrl+c, I can only
terminate the child process invoked by system, the script itself is
still running. Then I have to open another term to kill the script by
its pid.
I want to know how can I kill the script process by ctrl+c directly in
this conditon. Please aware that I can not use the return value of
system to do this. Because even the return value of system means a
error, the script just think this iteration failed, it will continue
the next iteration.
2. It seems change the $ENV{"xxx"} only takes effect in child process.
How can I set the enviroment variable in the middle of a perl script?
For example, I want to change the $LANG several times, so that I can
print different language's time format by using "localtime"
Thanks