Re: [racket-users] How to break a process created with system

2015-08-09 Thread Matthew Flatt
Does `(current-subprocess-custodian-mode 'kill)` combined with Cmd-k
(for kill, instead of break) make the subprocess terminate?

If so, you could use `dynamic-wind` or catch `exn:break` exceptions,
possibly put the subprocess under its own custodian, and so on.

At Sun, 9 Aug 2015 15:17:19 +0200, Jens Axel Søgaard wrote:
 Hi All,
 
 The function node below takes the path of a JavaScript file, starts
 node (JavaScript evaluator) using system. The output is
 collected in a string.
 
 (define (node path)
   (with-output-to-string
   (λ ()
 (system (string-append /usr/local/bin/node(path-string
 path))
 
 The function is used from within DrRacket. If the JavaScript program doesn't
 terminate, I use cmd-b to break the process. Control is given back to the
 repl, but the node system process keeps running in the background - and
 needs to be killed manually.
 
 How can I kill the node system process from within DrRacket?
 
 One of my attempts that didn't work:
 
 (define (node path)
   (with-output-to-string
   (λ ()
 (parameterize ([current-subprocess-custodian-mode 'kill]
[subprocess-group-enabled  #t])
   (system (string-append /usr/local/bin/node   
 (path-string path)))
 
 -- 
 Jens Axel Søgaard
 
 -- 
 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.


[racket-users] How to break a process created with system

2015-08-09 Thread Jens Axel Søgaard
Hi All,

The function node below takes the path of a JavaScript file, starts
node (JavaScript evaluator) using system. The output is
collected in a string.

(define (node path)
  (with-output-to-string
  (λ ()
(system (string-append /usr/local/bin/node(path-string
path))

The function is used from within DrRacket. If the JavaScript program doesn't
terminate, I use cmd-b to break the process. Control is given back to the
repl, but the node system process keeps running in the background - and
needs to be killed manually.

How can I kill the node system process from within DrRacket?

One of my attempts that didn't work:

(define (node path)
  (with-output-to-string
  (λ ()
(parameterize ([current-subprocess-custodian-mode 'kill]
   [subprocess-group-enabled  #t])
  (system (string-append /usr/local/bin/node   
(path-string path)))

-- 
Jens Axel Søgaard

-- 
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.


Re: [racket-users] How to break a process created with system

2015-08-09 Thread Jens Axel Søgaard
2015-08-09 15:24 GMT+02:00 Matthew Flatt mfl...@cs.utah.edu:

 Does `(current-subprocess-custodian-mode 'kill)` combined with Cmd-k
 (for kill, instead of break) make the subprocess terminate?


Yes.

If so, you could use `dynamic-wind` or catch `exn:break` exceptions,
 possibly put the subprocess under its own custodian, and so on.


Thanks that worked. For the archives:

(define (node/break path)
  (define me(current-thread))
  (define cust  (make-custodian))
  (define (kill)(custodian-shutdown-all cust))
  (define (on-break _)  (kill) \break: node process was killed\)
  (parameterize ([current-subprocess-custodian-mode 'kill]
 [subprocess-group-enabled  #t]
 [current-custodian cust])
(with-handlers ([exn:break? on-break])
  (thread (λ() (thread-send me (node path
  (thread-receive

/Jens Axel



 At Sun, 9 Aug 2015 15:17:19 +0200, Jens Axel Søgaard wrote:
  Hi All,
 
  The function node below takes the path of a JavaScript file, starts
  node (JavaScript evaluator) using system. The output is
  collected in a string.
 
  (define (node path)
(with-output-to-string
(λ ()
  (system (string-append /usr/local/bin/node   
 (path-string
  path))
 
  The function is used from within DrRacket. If the JavaScript program
 doesn't
  terminate, I use cmd-b to break the process. Control is given back to the
  repl, but the node system process keeps running in the background - and
  needs to be killed manually.
 
  How can I kill the node system process from within DrRacket?
 
  One of my attempts that didn't work:
 
  (define (node path)
(with-output-to-string
(λ ()
  (parameterize ([current-subprocess-custodian-mode 'kill]
 [subprocess-group-enabled  #t])
(system (string-append /usr/local/bin/node   
  (path-string path)))
 
  --
  Jens Axel Søgaard
 
  --
  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.




-- 
-- 
Jens Axel Søgaard

-- 
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.