-
as seen on Stack Overflow
- Search for 'Stack Overflow'
so if I do:
dup2(0, backup); // backup stdin
dup2(somefile, 0); // somefile has four lines of content
fgets(...stdin); // consume one line
fgets(....stdin); // consume two lines
dup2(backup, 0); // switch stdin back to keyboard
I am finding at this point.. stdin still contains the two lines I haven't…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
I see it's easy to open pipe between two process using fork, but how we can passing open pipe to threads.
Assume we need to pass out of PROGRAM A to PROGRAM B "may by more than one thread",
PROGRAM B send his output to PROGRAM C
#include <stdio.h>
#include <stdlib.h>
#include <pthread…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
I see it's easy to open pipe between two process using fork, but how we can passing open pipe to threads.
Assume we need to pass out of PROGRAM A to PROGRAM B "may by more than one thread",
PROGRAM B send his output to PROGRAM C
#include <stdio.h>
#include <stdlib.h>
#include <pthread…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
I want to use dup2 to read from input file and redirect it to the input of exec function. but my problem is i have three running process all of them have to open same input file but they do different jobs. what your suggest in such case? i don't know if it is possible to use "cat data.txt" to feed…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
Hello
I have tried to do fork() and piping in main and it works perfectly fine but when I try to implement it in a function for some reason I don't get any output, this is my code:
void cmd(int **pipefd,int count,int type, int last);
int main(int argc, char *argv[]) {
int pipefd[3][2];
int…
>>> More