c - Why does using `execl` instead of `system` stops my program from working? -
i'm trying basic ipc using pipes. spent hours searching internet, doing , that, reading api documentations, , ended code below. not work, quite expected. making code 'work' many thanks. <edit> i've found using system instead of execl makes program run expected. going wrong here when use execl , while doesn't happen system function? </edit> #include <stdio.h> #include <stdlib.h> #include <unistd.h> int main(void){ int hinpipe[2]; int houtpipe[2]; file *hinfile; file *houtfile; char *s; pipe(hinpipe); pipe(houtpipe); if(fork()){ close(hinpipe[0]); close(houtpipe[1]); hinfile=fdopen(hinpipe[1],"w"); fprintf(hinfile,"2^100\n"); fclose(hinfile); houtfile=fdopen(houtpipe[0],"r"); fscanf(houtfile,"%ms",&s); fclose(houtfile); printf("%s\n",s); free(s); }else{ ...