CSC209H1 Lecture Notes - C Dynamic Memory Allocation, C String Handling, System Call
Document Summary
Ex. build a simple shell showexec. c: the exec system call replaces the program being run by a process by a different one; i. e. replace a process"s memory contents. The new program starts executing from the beginning: on success, exec never returns, on failure, exec returns -1, ex. Program x program y int i = 5; printf(hellon, i); printf(%dn, i); exec(y); printf(%dn, i); // reach here = something wrong. 5: after exec new process inherits from calling process: Just different instructions: 6 versions of exec execl(char *path, char *arg0, , (char *)null); execv(char *path, char *argv[]); Suffix: v for vector, l for list. Ways to pass in arguments for the executable. L list out all the arguments. V pass in an array of arguments. Last element of the argv array has to be null to indicate the end for both l or v options.