#include
#include
int main()
{
fork();
fork() && fork() || fork();
fork();
printf
You should not use fork() like this. Never. And, nevertheless, you won't need to do so in real life. How to use it:
int main() {
/* code */
pid_t pid = fork();
if (pid < 0) {
/* error, no child process spawned */
}
if (pid > 0) {
/* we are the parent process, pid is the process ID of the ONE child process spawned */
}
/* else, we are the child process, running exactly one command later the fork() was called in the parent. */
/* some more code */
return 0;
}