[DCPM] platform independence and processes

Neil Williams linux at codehelp.co.uk
Thu Jul 8 16:36:10 CDT 2004


I'm using this code in a perl script to track rogue processes that just hang 
(due to errors in a Perl module, yes, it's Net::Z3950 again!)

It runs well on GNU/Linux - what are the likely problems, if any, of using 
these calls on other platforms?

The code is called each time the script starts, typically that will be via 
cron or some other scheduling tool for the appropriate OS.

# kill old instances of this script that might
# have crashed or hung.
chdir();
if( -r 'fallbackisbn.pid' ) {
	open(PID,"fallbackisbn.pid");
	my $oldpid = <PID>;
	kill 'TERM', $oldpid;
}

if(!(open(PID,">fallbackisbn.pid"))) {
	print STDERR 'Unable to open file in home directory, exiting.\n';
	exit(5);
}
print PID $$;
close(PID);

is kill a system call wrapper that is available only on Linux?
Will other platforms barff or just ignore the code?

-- 

Neil Williams
=============
http://www.codehelp.co.uk/
http://www.dclug.org.uk/
http://www.isbn.org.uk/
http://sourceforge.net/projects/isbnsearch/

http://www.biglumber.com/x/web?qs=0x8801094A28BCB3E3
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: signature
Url : http://mail.pm.org/pipermail/devoncornwall-pm/attachments/20040708/e9489362/attachment.bin


More information about the Devoncornwall-pm mailing list