[racket] racket and OS threads

From: Jukka Tuominen (jukka.tuominen at finndesign.fi)
Date: Fri Mar 18 08:57:34 EDT 2011

Thanks Matthew,

now the problem moved to converting the simple "system" procedure to not-so-simple "subprocess" procedure. My poor little non-programmer brain overloaded after seeing the following :)

---

(subprocess	stdout	 
 	 	stdin	 
 	 	stderr	 
 	 	command	 
 	 	arg ...)	 
 	→	 	
subprocess?
(or/c (and/c input-port? file-stream-port?) #f)
(or/c (and/c output-port? file-stream-port?) #f)
(or/c (and/c input-port? file-stream-port?) #f)
  stdout : (or/c (and/c output-port? file-stream-port?) #f)
  stdin : (or/c (and/c input-port? file-stream-port?) #f)
  stderr : (or/c (and/c output-port? file-stream-port?) #f)
  command : path-string?
  arg : string?
(subprocess	 	stdout	 
 	 	stdin	 
 	 	stderr	 
 	 	command	 
 	 	exact	 
 	 	arg)	 
 	→	 	
subprocess?
(or/c (and/c input-port? file-stream-port?) #f)
(or/c (and/c output-port? file-stream-port?) #f)
(or/c (and/c input-port? file-stream-port?) #f)
  stdout : (or/c (and/c output-port? file-stream-port?) #f)
  stdin : (or/c (and/c input-port? file-stream-port?) #f)
  stderr : (or/c (and/c output-port? file-stream-port?) #f)
  command : path-string?
  exact : 'exact
  arg : string?

---

An example in the documentation would be helpful. I often find them easier to follow.

I can't seem to initiate an OS thread anymore, and instead mapping a single thread identifier to a variable, there are now four outputs to joggle with.

Any further tips 
 1) converting system->subprocess so that the custodian process would print out both output and errors?
 2) capturing the subrocess identifier so that I have something to kill? :)

br, jukka




> -----Original Message-----
> From: Matthew Flatt [mailto:mflatt at cs.utah.edu]
> Sent: 18 March 2011 13:53
> To: Jukka Tuominen
> Cc: users at racket-lang.org
> Subject: Re: [racket] racket and OS threads
> 
> 
> At Fri, 18 Mar 2011 13:40:02 +0200, "Jukka Tuominen" wrote:
> > (define loop
> >   (lambda ()
> >        (set! thread:child (thread (lambda () (system "gracket -f
> > \""...rlt\""))))
> >        (sleep 30)
> >        (kill-thread thread:child)
> >        (loop)))
> > 
> > 
> > But, eventhough the racket process ends as expected, the OS 
> process still
> > stays alive.
> > 
> > Is there a way to kill the OS process as well?
> 
> See `current-subprocess-custodian-mode'.
> 




Posted on the users mailing list.