Fixing bug #59470
[u/mrichter/AliRoot.git] / MONITOR / AliChildProcTerminator.cxx
CommitLineData
c6d78c69 1// @(#)root/eve:$Id$
2// Author: Matevz Tadel 2007
3
4/**************************************************************************
5 * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
6 * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for *
7 * full copyright notice. *
8 **************************************************************************/
9
93624d6b 10#include "AliChildProcTerminator.h"
c6d78c69 11
12#include <sys/wait.h>
d42184d7 13#include <signal.h>
c6d78c69 14
15//______________________________________________________________________________
93624d6b 16// Full description of AliChildProcTerminator
c6d78c69 17//
18
93624d6b 19ClassImp(AliChildProcTerminator)
c6d78c69 20
93624d6b 21AliChildProcTerminator* AliChildProcTerminator::fgTheOne = 0;
c6d78c69 22
93624d6b 23AliChildProcTerminator* AliChildProcTerminator::Instance()
c6d78c69 24{
25 if (fgTheOne == 0)
93624d6b 26 fgTheOne = new AliChildProcTerminator;
c6d78c69 27 return fgTheOne;
28}
29
93624d6b 30AliChildProcTerminator::AliChildProcTerminator()
c6d78c69 31{
32 struct sigaction sac;
33 sac.sa_handler = sig_handler;
34 sigemptyset(&sac.sa_mask);
35 sac.sa_flags = 0;
36 sigaction(SIGCHLD, &sac, 0);
37}
38
93624d6b 39void AliChildProcTerminator::sig_handler(int /*sig*/)
c6d78c69 40{
41 int status;
42 pid_t pid = wait(&status);
93624d6b 43 Instance()->ChildProcTerm(pid, status);
c6d78c69 44}
45
93624d6b 46void AliChildProcTerminator::ChildProcTerm(Int_t pid, Int_t status)
c6d78c69 47{
48 Long_t args[2];
49 args[0] = (Long_t) pid;
50 args[1] = (Long_t) status;
51
93624d6b 52 Emit("ChildProcTerm(Int_t,Int_t)", args);
c6d78c69 53}