Page 1 of 1

process

Posted: Thu Sep 28, 2006 9:42 am
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?

Posted: Thu Sep 28, 2006 12:14 pm
by Lutz
Could you send it a quit command?

Code: Select all

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

Posted: Thu Sep 28, 2006 1:23 pm
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.

Posted: Sun Oct 01, 2006 9:50 pm
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?