process

Q&A's, tips, howto's
Locked
cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

process

Post by cormullion »

In this example (basically from the manual - I've added an (exit)):

Code: Select all

(map set '(bcin myout) (pipe))
(map set '(myin bcout) (pipe))

(process "bc" bcin bcout)
(set 'sum "123456789012345 * 123456789012345")

(write-buffer myout (string sum "\n"))
(set 'answer (read-line myin))
(println (string sum " = " answer))
(exit)
'bc' is still running, I think. How should I be stopping it?

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

Could you send it a quit command?

Code: Select all

(write-buffer myout "quit\n")
Lutz

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Post by cormullion »

yes, that works and stops the creation of orphaned processes with "S" status, I suppose. Thanks.

I've got processes with "Z" status too - Zombies?. These must have been caused by something else I've been doing recently (trying out all the OS commands...) :-)

While on the subject of processes, what's the best way to write and run a newLISP program that runs continuously, like the ntpd or launchd daemon, and does a task every minute or so? Rather than call a one-shot script from 'cron' or something.

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Post by cormullion »

Perhaps a different question. I want to write a script that runs in the background all the time I'm logged in. I've got two approaches to a continuous loop. Which is the better:

Code: Select all

(while true
	(do-stuff)
	(sleep 10000))

Code: Select all

(define (ticker) 
    (do-stuff)
    (timer 'ticker 10.0))
(ticker)
Is it best launched one of the command-line options?

Locked