Fork,exec wait and exit system calls

Hi All..
I read that fork intiates a process and exec executes it and exit exits the process and wait command makes the parent wait for the child's exit status.

But I am unable to correlate what does that actually mean?
When I execute a command in shell( main.cpp ,cat foo,mkdir DIR)..are these different stages when this command is being executed?
Where all these sysstem calls are used?

It could be very beginner question....but I am clueless....Please help.

Thanks in advance
closed account (S6k9GNh0)
system calls such as that tend to be very well documented in the POSIX libraries (which overlies C might I add):

Upon a successful call to fork(), the process is already running. You have to use logic to determine which process your current logic is running in by checking its return status.

exec[v] on the other hand is use to start a separate process with logic stored elsewhere (usually an ELF binary):

Exit can exit the process but I wouldn't recommend such a sudden stop-all function. You have to clean up after yourself in any given context or your program might have unwanted side-effects. You can use atexit() but it's generally not that great for threaded environments and isn't very well featured.
Last edited on
Topic archived. No new replies allowed.