Brand new GUI application for online display/reco by Matevz.
[u/mrichter/AliRoot.git] / MONITOR / AliChildReaper.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
10#include "AliChildReaper.h"
11
12#include <sys/wait.h>
13
14//______________________________________________________________________________
15// Full description of AliChildReaper
16//
17
18ClassImp(AliChildReaper)
19
20AliChildReaper* AliChildReaper::fgTheOne = 0;
21
22AliChildReaper* AliChildReaper::Instance()
23{
24 if (fgTheOne == 0)
25 fgTheOne = new AliChildReaper;
26 return fgTheOne;
27}
28
29AliChildReaper::AliChildReaper()
30{
31 struct sigaction sac;
32 sac.sa_handler = sig_handler;
33 sigemptyset(&sac.sa_mask);
34 sac.sa_flags = 0;
35 sigaction(SIGCHLD, &sac, 0);
36}
37
38void AliChildReaper::sig_handler(int /*sig*/)
39{
40 int status;
41 pid_t pid = wait(&status);
42 Instance()->ChildDeath(pid, status);
43}
44
45void AliChildReaper::ChildDeath(Int_t pid, Int_t status)
46{
47 Long_t args[2];
48 args[0] = (Long_t) pid;
49 args[1] = (Long_t) status;
50
51 Emit("ChildDeath(Int_t,Int_t)", args);
52}