Fix most instances of fork by replacing with xfork, name xfork correctly

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@306 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
jbjohnso 2008-01-21 19:49:59 +00:00
parent 39c7de2940
commit b8b4e74f04
7 changed files with 18 additions and 14 deletions

View File

@ -47,7 +47,7 @@ sub fork_no_output
my $pid;
if ($pid = fork)
if ($pid = xCAT::Utils->xfork)
{
}

View File

@ -2,6 +2,7 @@
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
package xCAT::MacMap;
use xCAT::Table;
use xCAT::Utils;
use IO::Select;
use IO::Handle;
use Sys::Syslog;
@ -140,7 +141,7 @@ sub refresh_table {
$child->autoflush(1);
$parent->autoflush(1);
$children++;
$cpid = fork;
$cpid = xCAT::Utils->xfork;
unless (defined $cpid) { die "Cannot fork" };
if ($cpid == 0) {
close($child);

View File

@ -3,6 +3,7 @@
package xCAT::PPC;
use strict;
use xCAT::Table;
use xCAT::Utils;
use POSIX "WNOHANG";
use Storable qw(freeze thaw);
use Time::HiRes qw(gettimeofday);
@ -464,7 +465,7 @@ sub fork_cmd {
my $parent;
my $child;
pipe $parent, $child;
my $pid = fork;
my $pid = xCAT::Utils->xfork;
if ( !defined($pid) ) {
###################################

View File

@ -97,14 +97,14 @@ sub isAIX
#-------------------------------------------------------------------------------
=head3 tfork
=head3 xfork
forks, safely coping with open database handles
Argumens:
none
Returns:
same as fork
=cut
sub tfork {
sub xfork {
my $rc=fork;
unless (defined($rc)) {
return $rc;

View File

@ -3,6 +3,7 @@
package xCAT_plugin::blade;
#use Net::SNMP qw(:snmp INTEGER);
use xCAT::Table;
use xCAT::Utils;
use IO::Socket;
use SNMP;
use strict;
@ -948,7 +949,7 @@ sub process_request {
pipe $cfd, $pfd;
$cfd->autoflush(1);
$pfd->autoflush(1);
my $cpid = fork;
my $cpid = xCAT::Utils->fork;
unless (defined($cpid)) { die "Fork error"; }
unless ($cpid) {
close($cfd);

View File

@ -7,6 +7,7 @@ $xcat_plugins{ipmi}="this";
package xCAT_plugin::ipmi;
use Storable qw(store_fd retrieve_fd thaw freeze);
use xCAT::Utils;
require Exporter;
@ISA = qw(Exporter);
@ -558,7 +559,7 @@ sub ipmicmd {
mkfifo("/tmp/.sol.$pid",0666);
my $child = fork();
my $child = xCAT::Utils->xfork();
if(!defined $child) {
die;
}

View File

@ -71,7 +71,7 @@ sub daemonize {
chdir('/');
umask 0;
my $pid;
defined($pid = fork) or die "Can't fork: $!";
defined($pid = xCAT::Utils->xfork) or die "Can't fork: $!";
if ($pid) {
if ($pidfile) {
open(PFILE, '>', $pidfile);
@ -152,7 +152,7 @@ if (xCAT::Utils->isLinux()) {
arg => [ 'next' ],
);
close($conn);
my $pid=fork();
my $pid=xCAT::Utils->xfork();
unless ($pid) { #fork off the nodeset and potential slowness
plugin_command(\%request,undef,\&convey_response);
exit(0);
@ -185,7 +185,7 @@ if (xCAT::Utils->isLinux()) {
node => [ $node ],
arg => [ 'enact' ],
);
my $pid=fork();
my $pid=xCAT::Utils->xfork();
unless ($pid) { #fork off the nodeset and potential slowness
plugin_command(\%request,undef,\&convey_response);
exit(0);
@ -322,14 +322,14 @@ daemonize;
$SIG{CHLD} = sub { while (waitpid(-1,WNOHANG) > 0) {} };
$SIG{TERM} = $SIG{INT} = sub { printf("Asked to quit...\n"); $quit++ };
my $pid = fork;
my $pid = xCAT::Utils->xfork;
defined $pid or die "Unable to fork for UDP/TCP";
unless ($pid) {
$$progname="xcatd: UDP listener";
do_udp_service;
exit(0);
}
$pid = fork;
$pid = xCAT::Utils->xfork;
defined $pid or die "Unable to fork installmonitor";
unless ($pid) {
$$progname="xcatd: install monitor";
@ -365,7 +365,7 @@ xCAT_monitoring::monitorctrl::start($$);
my $peername;
until ($quit) {
next unless my $connection=$listener->accept;
my $child = fork(); #Yes we fork, IO::Socket::SSL is not threadsafe..
my $child = xCAT::Utils->xfork(); #Yes we fork, IO::Socket::SSL is not threadsafe..
unless (defined $child) {
die "xCATd cannot fork";
@ -521,7 +521,7 @@ sub plugin_command {
#pipe($pfd,$cfd);
$parent_fd->autoflush(1);
$pfd->autoflush(1);
$child = fork;
$child = xCAT::Utils->xfork;
} else {
$child = 0;
}