linux - How to change the fd associated with the stdin file descriptor? -


i want associate pipe's write fd stdout.

int pfds[2]; char buf[30];  if (pipe(pfds) == -1) {     perror("pipe");     exit(1); }  want associate pfd[1] stdout of process.  

i understand, can use freopen redirect stdout file. hoping similar this.

dup2(2) easiest way:

dup2(pfds[1], stdout_fileno); 

Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -