home *** CD-ROM | disk | FTP | other *** search
- There are now three new functions for dealing with processes:
- *process
- *process-send
- *process-receive
-
- These functions are designed to replace the 'process' function, which, due
- to its nlambda'ness, was difficult to use. All of the above functions
- are lambda's or lexpr's.
-
- See chapter 6 of the manual (its on-line) for the details of these
- functions. This is a quick summary:
-
- (*process-send 'st_command)
- tells the shell to run the command st_command concurrently, and returns
- a write-only port. Characters written to this port will appear at
- the standard input of st_command.
- example:
- (setq p (*process-send "mail jkf"))
- (print 'HiThere p)
- (close p)
-
-
- (*process-receive 'st_command)
- tells the shell to run st_command concurrently, and returns a
- read-only port. Characters written to the standard output by
- st_command will be available by reading from the given port.
- Characters written on the standard error by st_command will
- appear on lisp's the standard error (the terminal most likely).
- example:
- ; to see if foo is logged in:
- (setq p (*process-receive "u"))
- (do ((user (read p '**eof**) (read p '**eof**)))
- ((eq '**eof** user) (print 'Not-Logged-In))
- (cond ((eq 'foo user) (print 'Is-Logged-In))))
- (close p)
-
-
- (*process 'st_command ['g_readp ['g_writep]])
- this is the general function which process, *process-send and
- *process-receive call. If called with one argument it
- starts the new process and waits for it to end, e.g:
- (*process (concat "vi " filename))
- In this case *process return the exit code of the process.
-
- The g_readp and g_writep arguments, if given, tell *process to
- run the process concurrently. If g_read is non nil then
- *process will return a port just like *process-receive.
- If g_writep is non-nil, then *process will set up a pipe like
- *process-send.
- *process will return a list of the form
- (readport writeport process-id)
- where readport and writeport will only be a port if g_readp
- or g_writep are non nil.
-
-
- A little know fact about processes is that a process, once started,
- cannot die and disappear until its parent asks about its status.
- Take the mail example given above:
- (setq p (*process-send "mail jkf"))
- (print 'HiThere p)
- (close p)
- after the mail process finishes it work, it will attempt to die, returning
- an integer called the 'exit status'. However until the lisp program
- asks about its status the mail process will remain in existence
- in a Zombie state, somewhere between life and death. ps will show this:
-
- PID TT STAT TIME COMMAND
- 3876 p0 Z 0:01 <exiting>
-
- A user is only allowed a small number of processes, so if you continue
- to generate processes and leave them around as Zombies, you will eventually
- run out of processes. The way to let the Zombie die is to call
- the wait function, e.g.
- -> (wait)
- (3876 . 0)
- ->
- this says that process 3876 died with exit status 0.
-
- Also, when you exit lisp the shell will clean up the Zombies.
-
- If you start a process with (*process "vi foo") then lisp will wait
- for it to complete before continuing, so you don't have to worry about
- Zombies. You only have to worry if you run a process concurrently,
- such as when you use *process-send or *process-receive.
-
-
-
-
-
-
-
-