SYS-CALL

make a system call to the host operating system
Major Section:  PROGRAMMING

Example Forms:
(sys-call "cp" '("foo.lisp" "foo-copied.lisp"))
(prog2$ (sys-call "cp" '("foo.lisp" "foo-copied.lisp"))
        (sys-call-status state))
The first argument of sys-call is a command for the host operating system, and the second argument is a list of strings that are the arguments for that command. In GCL and perhaps other lisps, you can put the arguments with the command; but this is not the case, for example, in Allegro CL running on Linux.

The use of prog2$ above is optional, but illustrates a typical sort of use when one wishes to get the return status. See sys-call-status.

General Form:
(sys-call cmd args)
This function logically returns nil. However, it makes the indicated call to the host operating system, as described above, using a function supplied ``under the hood'' by the underlying Lisp system. On occasions where one wishes to obtain the numeric status returned by the host operating system (or more precisely, by the Lisp function under the hood that passes the system call to the host operating system), one may do so; see sys-call-status. The status value is the value returned by that Lisp function, which may well be the same numeric value returned by the host operating system for the underlying system call.

Note that sys-call does not touch the ACL2 state; however, sys-call-status updates the file-clock field of the state. One may view that update as modifying the fileclock to be at least as recent as the time of the most recent sys-call.

Finally, we make a comment about output redirection, which also applies to other related features that one may expect of a shell. Sys-call does not directly support output redirection. If you want to run a program, P, and redirect its output, we suggest that you create a wrapper script, W to call instead. Thus W might be a shell script containing the line:

P $* >& foo.out
If this sort of solution proves inadequate, please contact the ACL2 implementors and perhaps we can come up with a solution.