Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Matts (1087)

Matts
  (email not shown publicly)

I work for MessageLabs [messagelabs.com] in Toronto, ON, Canada. I write spam filters, MTA software, high performance network software, string matching algorithms, and other cool stuff mostly in Perl and C.

Journal of Matts (1087)

Tuesday November 05, 2002
04:04 AM

exec() problems sussed.

[ #8766 ]

I figured it out. Here's what I'm doing now - when I wait for clamd's socket to appear, I also check if the child process still exists using kill(0 => $pid). If it no longer exists, then it must have died somehow, and we have to stop the test.

Thanks Ovid and jm for allowing me to bounce thoughts around.

Full code sample:

my $pid = fork;
die "Fork failed" unless defined $pid;
if (!$pid) {
    exec "eclamd -c clamav.conf";
    die "Clamd failed to start: $!";
}
for (1..10) {
  last if (-e "clamsock");
  if (kill(0 => $pid) == 0) {
    die "Clamd appears to have died";
  }
  sleep(1);
}

It's possible I can turn the for (1..10) into a while(1) now, but I think I'll leave it like that for now.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.