Skip to content

Instantly share code, notes, and snippets.

@ha7ilm
Created December 2, 2015 19:49
Show Gist options
  • Save ha7ilm/40e57a7b636a1351800e to your computer and use it in GitHub Desktop.
Save ha7ilm/40e57a7b636a1351800e to your computer and use it in GitHub Desktop.
stdin behaviour test, 3 processes
#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