]>
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 "AliChildProcTerminator.h" | |
11 | ||
12 | #include <sys/wait.h> | |
13 | #include <signal.h> | |
14 | ||
15 | //______________________________________________________________________________ | |
16 | // Full description of AliChildProcTerminator | |
17 | // | |
18 | ||
19 | ClassImp(AliChildProcTerminator) | |
20 | ||
21 | AliChildProcTerminator* AliChildProcTerminator::fgTheOne = 0; | |
22 | ||
23 | AliChildProcTerminator* AliChildProcTerminator::Instance() | |
24 | { | |
25 | if (fgTheOne == 0) | |
26 | fgTheOne = new AliChildProcTerminator; | |
27 | return fgTheOne; | |
28 | } | |
29 | ||
30 | AliChildProcTerminator::AliChildProcTerminator() | |
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 | ||
39 | void AliChildProcTerminator::sig_handler(int /*sig*/) | |
40 | { | |
41 | int status; | |
42 | pid_t pid = wait(&status); | |
43 | Instance()->ChildProcTerm(pid, status); | |
44 | } | |
45 | ||
46 | void AliChildProcTerminator::ChildProcTerm(Int_t pid, Int_t status) | |
47 | { | |
48 | if (pid < 0) return; | |
49 | ||
50 | Long_t args[2]; | |
51 | args[0] = (Long_t) pid; | |
52 | args[1] = (Long_t) status; | |
53 | ||
54 | Emit("ChildProcTerm(Int_t,Int_t)", args); | |
55 | } |