@@ -33,9 +33,6 @@ inputCon <- socketConnection(
3333# Waits indefinitely for a socket connecion by default.
3434selectTimeout <- NULL
3535
36- # Exit code that children send to the parent to indicate they exited.
37- exitCode <- 1
38-
3936while (TRUE ) {
4037 ready <- socketSelect(list (inputCon ), timeout = selectTimeout )
4138
@@ -62,18 +59,7 @@ while (TRUE) {
6259 children <- parallel ::: selectChildren(timeout = 0 )
6360
6461 if (is.integer(children )) {
65- lapply(children , function (child ) {
66- # This data should be raw bytes if any data was sent from this child.
67- # Otherwise, this returns the PID.
68- data <- parallel ::: readChild(child )
69- if (is.raw(data )) {
70- # This checks if the data from this child is the exit code that indicates an exited child.
71- if (unserialize(data ) == exitCode ) {
72- # If so, we terminate this child.
73- tools :: pskill(child , tools :: SIGUSR1 )
74- }
75- }
76- })
62+ lapply(children , function (child ) { tools :: pskill(child , tools :: SIGUSR1 ) })
7763 } else if (is.null(children )) {
7864 # If it is NULL, there are no children. Waits indefinitely for a socket connecion.
7965 selectTimeout <- NULL
@@ -97,7 +83,7 @@ while (TRUE) {
9783 try(source(script ))
9884 # Note that this mcexit does not fully terminate this child. So, this writes back
9985 # a custom exit code so that the parent can read and terminate this child.
100- parallel ::: mcexit(0L , send = exitCode )
86+ parallel ::: mcexit(0L )
10187 } else {
10288 # Forking succeeded and we need to check if they finished their jobs every second.
10389 selectTimeout <- 1
0 commit comments