pileofrogs has asked for the wisdom of the Perl Monks concerning the following question:
First, yes, I read the FAQ, I tried a handler on SIG{INT}.
I'm working on a script that runs rsync every few seconds and I'd like to be able to handle CTRL-C gracefully, which means letting rsync finish what it's doing before exiting.
Right now, rsync catches CTRL-C, not my script, so my script keeps running and rsync gets interrupted.
Here's a reeeealy short psudo-code version of my script
$SIG{INT} = \&blah; sub blah { sleep 10; exit; } while (1) { system("rsync -a rsync://blah.example.com/foo foo"); sleep 5; }
Hmmmm... Writing this I think I see the problem. I need to fork off the rsync job somehow so my perl script will actually be running at the time it gets signalled...
What's the best way to handle that? (If I've got this figured out that is...)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: protect children from SIG{INT}
by Zaxo (Archbishop) on Nov 18, 2005 at 01:37 UTC | |
by pileofrogs (Priest) on Nov 18, 2005 at 02:42 UTC | |
by sgifford (Prior) on Nov 18, 2005 at 02:38 UTC | |
by Zaxo (Archbishop) on Nov 18, 2005 at 09:13 UTC | |
by QM (Parson) on Nov 18, 2005 at 15:12 UTC | |
by sgifford (Prior) on Nov 18, 2005 at 16:18 UTC | |
by pileofrogs (Priest) on Nov 18, 2005 at 16:57 UTC |