diff --git a/perl-xCAT/xCAT/Table.pm b/perl-xCAT/xCAT/Table.pm index 26e1af38a..a2c43e26f 100644 --- a/perl-xCAT/xCAT/Table.pm +++ b/perl-xCAT/xCAT/Table.pm @@ -70,6 +70,7 @@ my $dbworkersocket; my $dbsockpath = "/tmp/xcat/dbworker.sock"; my $exitdbthread; my $dbobjsforhandle; +my $intendedpid; sub dbc_call { @@ -150,6 +151,7 @@ sub init_dbworker { die "Error spawining database worker"; } unless ($dbworkerpid) { + $intendedpid = $$; $SIG{CHLD} = sub { while (waitpid(-1,WNOHANG) > 0) {}}; #avoid zombies from notification framework #This process is the database worker, it's job is to manage database queries to reduce required handles and to permit cross-process caching $0 = "xcatd: DB Access"; @@ -200,6 +202,9 @@ sub init_dbworker { my $err=$@; xCAT::MsgUtils->message("S","xcatd: possible BUG encountered by xCAT DB worker ".$err); } + if ($intendedpid != $$) { #avoid redundant fork + exit(0); + } } close($dbworkersocket); unlink($dbsockpath);