The document discusses system calls fork, wait, and exec. Fork duplicates a process and returns 0 in the child and the child's PID in the parent. Wait makes the parent wait for the child to finish. Exec replaces the current process with a new program.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
10 views9 pages
Process System Calls
The document discusses system calls fork, wait, and exec. Fork duplicates a process and returns 0 in the child and the child's PID in the parent. Wait makes the parent wait for the child to finish. Exec replaces the current process with a new program.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 9
Process System Calls
fork – wait – exec
fork • used to duplicate a process Syntax • pid_t fork(void); Example int main() { pid_t p; p=fork(); If(p==0){ printf(“Child process\n");} else{ printf(“Parent process);} } What fork() returns • On failure • -1 • On success • ‘0’ in the child process • Process-id of the child in the parent process. wait() • Makes the parent wait for the child to finish Syntax • pid_t wait(int *wstatus); Important • wait() can be used to make the parent wait for the child to terminate(finish) but not the other way around. For More • https://dextutor.com/fork-system-call/