When you use `system` or `process`, the immediate new process runs a shell. The shell process then starts another one to run the command that you give it.
I recommend using `process*` to avoid the shell process and to avoid encoding issues when passing arguments: (define racket (find-executable-path "racket")) ... (process* racket "sleeper.rkt") ... Another approach is to create a fresh process group for the shell process, and then `((fifth pl) 'kill)` kills the whole group: (parameterize ([subprocess-group-enabled #t]) (process "racket sleeper.rkt")) Finally, you could tell the shell to not create a subprocess and instead replace itself with the other program" (process "exec racket sleeper.rkt") At Thu, 7 Apr 2016 13:47:39 -0700 (PDT), Wayne Iba wrote: > I'm having trouble with two interacting processes and am hoping someone can > point out whatever it is that I'm missing. > > Process A starts process B and interacts with it but conditionally needs to > kill it. But using the procedure of one argument returned (as the fifth > element of a list) by process does not seem to kill it. I've tried "kill -9 > <pid>" with system with no joy either. Here is my code and the output from > killer. > ======================= > ;code for sleeper in a separate file > (define (sleeper) > (for ([i 7]) > (sleep 4) > (printf "~a~%" i)(flush-output))) > (sleeper) > ======================= > ;code for killer in another file -- I run this as "racket killer.rkt" > (define (killer) > (let ([pl (process "racket sleeper.rkt")]) > (for ([l (in-port read-line (first pl))]) > (printf "status: ~a~%" ((fifth pl) 'status)) > (if (= (with-input-from-string l read) 2) > (begin > ;(system (string-append "kill -9 " (number->string (third pl)))) > ((fifth pl) 'kill) > ) > (displayln l))) > (close-input-port (first pl)) > (close-output-port (second pl)) > (close-input-port (fourth pl)) > )) > (killer) > ======================= > ;; output from killer > status: running > status: running > 0 > status: running > 1 > status: running > status: done-error > 3 > status: done-error > 4 > status: done-error > 5 > status: done-error > 6 > ======================= > > So what am I missing? Thanks in advance! > > -- > You received this message because you are subscribed to the Google Groups > "Racket Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to racket-users+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.