Next: fork() Up: Running UNIX Commands from C Previous: Running UNIX Commands from C

execl()

execl has 5 other related functions - see man pages.

execl stands for execute and leave which means that a process will get executed and then terminated by execl.

It is defined by:

execl(char *path, char *arg0,...,char *argn, 0);

The last parameter must always be 0. It is a NULL terminator. Since the argument list is variable we must have some way of telling C when it is to end. The NULL terminator does this job.

where path points to the name of a file holding a command that is to be executed, argo points to a string that is the same as path (or at least its last component.

arg1 ... argn are pointers to arguments for the command and 0 simply marks the end of the (variable) list of arguments.

So our above example could look like this also:


Dave.Marshall@cm.cf.ac.uk
Wed Sep 14 10:06:31 BST 1994