pipe
I've done simple cat /etc/passwd pipe in c. But how do I know if this is working like a bash command. It doesn't print anything.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
int main(){
int fds1[2];
pid_t pid;
pipe(fds1);
if((pid = fork())== 0){
dup2(fds1[1],1);
close(fds1[0]);
close(fds1[1]);
execl("/bin/cat","cat","/etc/passwd",NULL);
}
}
|
Topic archived. No new replies allowed.