-> (get-env "TERM") "xterm" -> (set-env "TERM" "vt100") "vt100"
system runs a command in the sh shell, and returns the program's exit status, or -1 if unsuccessful. Calling system with no arguments returns True or False depending on whether an sh command interpreter is available.
-> (system "date") Mon Aug 16 15:51:48 EDT 1999 0 -> (execute "boguscommand") ** exec: Unable to execute boguscommand. Null -> (execute "xv picture.jpg")
-> (get-process-id) 4017 -> (get-parent-id) 1313 -> (get-user-id) 31443 -> (get-group-id) 2000
wait blocks until a child process exits. Both functions accept either no arguments or an integer process id. When no argument is passed, the status of any child process is returned. The return value is a list containing the process id and the status (0 if the process no longer exists or exited).
(set pid (fork)) # create new process (if (= 0 pid) # if this is the child process (begin (exec "xclock") # run a command (exit))) # exit if exec returns in failure (print "Child id: " pid newline) # this is what happens in the parent (set status (wait pid)) # wait for child to complete (print "Child completed with exit status: " (status 1) newline)
The dup function is normally used in Unix to duplicate a file handle into the standard input or standard output of a program about to be executed. Passing two integers or Unix FD ports closes the first port, and duplicates the first port into the second port. pipe and dup are often used in conjunction with each other to set up a new process whose standard input and output are connected to ports in an Isis process. For more information on these commands, please see their manual pages, or read a book on Unix programming.
The example function below creates a pipe, creates a new process, duplicates the input end of the pipe into the standard input (file handle 0) of the new process, and then runs the line printer program. Thus, any data written to the other end of the pipe will be transferred into the standard input of the "lpr" command and appear on the printer!
send-signal sends a signal to the process and returns True if successful or False if not. See below for a list of possible signals to send. Some of the most useful signals are perhaps sig-interrupt and sig-kill which terminate the receiving process.
(set send-text-to-printer (proc (text) (local (pipeinfo iport oport pid) (begin (set pipeinfo (pipe)) # create pipe (set iport (pipeinfo 0)) # this is the input end of the pipe (set oport (pipeinfo 1)) # this is the output end of the pipe (if (= 0 (set pid (fork))) # create new process (begin # if this is the child process, (close oport) # output end of pipe not needed in the child (dup iport 0) # duplicate input end into to the standard input (0) (exec "lpr"))) # execute the line printer program (close iport) # input end of pipe not needed in the parent (write-string oport text) # write text to lpr process (close oport))))) # close output end of pipe
The following constants may be used for the signal argument:
-> (send-signal 23904 sig-kill) True -> (send-signal 1 sig-kill) False
sig-hangup sig-interrupt sig-quit sig-illegal-instruction sig-trace-trap sig-abort sig-floating-exception sig-kill sig-bus sig-segmentation-fault sig-pipe sig-alarm sig-urgent sig-stop sig-interactive-stop sig-continue sig-child sig-tty-input sig-tty-output sig-io sig-window-change sig-user-1 sig-user-2
Threads in Isis are still under development and available for you to use on a trial basis only, and you must use a special interpreter called multi-isis. The thread interface is currently very simple. To create a new thread running a procedure, use the spawn operator, which will return a thread identifier or Null if an error occurred. join waits for the specified thread to finish and returns the result of the procedure application that was running it it, or Null if an error occurred. self returns the thread identifier of the current thread.