12
12
# interesting process exits
13
13
class WaitLoop (object ):
14
14
def __init__ (self , pid = None ):
15
- self .waitfor = pid
16
- self .status = None
15
+ self .waitfor = pid
16
+ self .status = None
17
17
def __call__ (self ):
18
18
try :
19
- (np , self .status )= os .wait ()
20
- while np is None or np != self .waitfor :
21
- (np , self .status )= os .wait ()
19
+ (nextpid , self .status ) = os .wait ()
20
+ while nextpid is None or nextpid != self .waitfor :
21
+ (nextpid , self .status ) = os .wait ()
22
22
except OSError :
23
- if np :
24
- print ("Chld process {} never exited, but no more children left" .format (self .waitfor ))
25
- self .status = - 1
23
+ if nextpid :
24
+ print ("Chld process {} never exited, but no more children left" .
25
+ format (self .waitfor ))
26
+ self .status = - 1
26
27
27
28
def main ():
28
- for f in os .listdir ("mount" ):
29
- src = os .path .join ("mount" , f )
30
- dst = os .path .join ("autolab" , f )
29
+ for copyfile in os .listdir ("mount" ):
30
+ src = os .path .join ("mount" , copyfile )
31
+ dst = os .path .join ("autolab" , copyfile )
31
32
shutil .copy (src , dst )
32
33
33
- autolabuser = pwd .getpwnam ("autolab" )
34
- (r_p , w_p )= os .pipe ()
35
- pid = os .fork ()
34
+ autolabuser = pwd .getpwnam ("autolab" )
35
+ (r_p , w_p ) = os .pipe ()
36
+ pid = os .fork ()
36
37
if pid == 0 :
37
38
os .close (r_p )
38
39
os .setgroups ([])
39
40
os .setgid (autolabuser .pw_gid )
40
41
os .setuid (autolabuser .pw_uid )
41
- args = ["autodriver" ]
42
+ args = ["autodriver" ]
42
43
args .extend (sys .argv [1 :])
43
44
args .append ("autolab" )
44
45
if w_p != 1 :
@@ -49,19 +50,19 @@ def main():
49
50
os .close (w_p )
50
51
os .execvp (args [0 ], args )
51
52
os .close (w_p )
52
- waiter = WaitLoop (pid )
53
- thr = threading .Thread (target = waiter )
53
+ waiter = WaitLoop (pid )
54
+ thr = threading .Thread (target = waiter )
54
55
thr .start ()
55
- rpf = os .fdopen (r_p )
56
+ rpf = os .fdopen (r_p )
56
57
shutil .copyfileobj (rpf , open ("mount/feedback" , "w" ))
57
58
#print("Copied output")
58
59
rpf .close ()
59
60
thr .join ()
60
61
# if core, exit -1, else pass through code.
61
62
if os .WIFSIGNALED (waiter .status ):
62
- status = - 1
63
+ status = - 1
63
64
else :
64
- status = os .WEXITSTATUS (waiter .status )
65
+ status = os .WEXITSTATUS (waiter .status )
65
66
#print("Status is {}".format(status))
66
67
sys .exit (status )
67
68
0 commit comments