Hi Loeung,

* loeung vidol <[EMAIL PROTECTED]> [07m31d01y 16:03]:
> How can I trap the 'Ctrl+C' combination in my script: shell, PERL, or even
> C, so that my script cannot be terminated by that?

In the shell (I'm assuming bash here) do this at the top of your script:

trap "" 2

That will set signal 2 (SIGINT, generated by ^C) to be ignored.

-

In perl, do this at the top of your script:

$SIG{"INT"} = IGNORE;

That also sets SIGINT to be ignored.

-

In C, you need to do this at the code for which you want ^C blocked:

signal(SIGINT, SIG_IGN);

That sets the SIGINT signal handler to the special value SIG_IGN, which
ignores the signal. Note you'll have to #include <signal.h> .


Hope that helps.



_______________________________________________
Seawolf-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/seawolf-list

Reply via email to