Belle II Software  release-08-01-10
run_processor.py
1 #! /usr/bin/env python
2 
3 
10 
11 import os
12 import sys
13 import signal
14 import subprocess
15 
16 global proc
17 
18 
19 # Signal Handler
20 def cleanup(num, frame):
21  # os.kill(proc.pid, signal.SIGKILL)
22  # os.kill(proc.pid, signal.SIGINT)
23  os.killpg(proc.pid, signal.SIGINT)
24  exit()
25 
26 # main
27 
28 
29 # Signal Handler
30 signal.signal(signal.SIGINT, cleanup)
31 signal.signal(signal.SIGTERM, cleanup)
32 
33 # Obtain input/output RingBuffer names
34 argvs = sys.argv
35 argc = len(argvs)
36 
37 inputrb = argvs[1]
38 outputrb = argvs[2]
39 histport = argvs[3]
40 # ncore = argvs[4]
41 ncore = "20"
42 
43 script = "processor.py"
44 
45 # run basf2
46 proc = subprocess.Popen("basf2 --no-stats " + script + " " + inputrb + " " + outputrb +
47  " " + histport + " " + ncore, shell=True, preexec_fn=os.setsid)
48 
49 # Just sleep
50 proc.wait()