Created
December 2, 2015 19:49
-
-
Save ha7ilm/40e57a7b636a1351800e to your computer and use it in GitHub Desktop.
stdin behaviour test, 3 processes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <unistd.h> | |
int main() | |
{ | |
pid_t p; | |
int stat; | |
int i; | |
for(i=0;i<3;i++) //<===== that's what changed! | |
if(!(p = fork())) | |
{ | |
execl("/bin/bash","bash", "-c","csdr through >/dev/null",NULL); | |
fprintf(stderr, "child failed to execl, now exits...\n"); return; | |
} | |
fprintf(stderr, "parent wait\n"); | |
while(1) wait(&stat); | |
fprintf(stderr, "parent exited\n"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment