]>
Commit | Line | Data |
---|---|---|
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 | ||
18 | ClassImp(AliChildReaper) | |
19 | ||
20 | AliChildReaper* AliChildReaper::fgTheOne = 0; | |
21 | ||
22 | AliChildReaper* AliChildReaper::Instance() | |
23 | { | |
24 | if (fgTheOne == 0) | |
25 | fgTheOne = new AliChildReaper; | |
26 | return fgTheOne; | |
27 | } | |
28 | ||
29 | AliChildReaper::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 | ||
38 | void AliChildReaper::sig_handler(int /*sig*/) | |
39 | { | |
40 | int status; | |
41 | pid_t pid = wait(&status); | |
42 | Instance()->ChildDeath(pid, status); | |
43 | } | |
44 | ||
45 | void 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 | } |