dup2 Questions
6
Solved
I'm implementing piping on a simulated file system in C++ (with mostly C). It needs to run commands in the host shell but perform the piping itself on the simulated file system.
I could achieve t...
3
Solved
1
Solved
I am trying to replace stdin with another pipe, then place the original stdin back to fd #0.
e.g.
dup2(p, 0); // p is a pre-existing fd of a pipe
exec(/* some commands */);
//what will be here i...
Ezraezri asked 25/12, 2018 at 18:44
8
Solved
I know that dup, dup2, dup3 "create a copy of the file descriptor oldfd"(from man pages). However I can't digest it.
As I know file descriptors are just numbers to keep track of file locations and...
1
Solved
Is there some magic I can do with dup2 (or fcntl), so that I redirect stdout to a file (i.e., anything written to descriptor 1 would go to a file), but then if I used some other mechanism, it would...
1
Solved
I'm posting my code simply for context of my question. I'm not explicitly looking for you to help fix it, I'm more so looking to understand the dup2 system call that I'm just not picking up from th...
1
Solved
I looked it up in the man page but I still don't get it...
let's say you have dup2(f1,0). Does that switch filedesc.1 with stdin and then locks stdin?
Nate asked 2/7, 2014 at 18:29
2
Solved
This manpage for the dup2 system call says:
EBUSY (Linux only) This may be returned by dup2() or dup3() during a
race condition with open(2) and dup().
What race condition does it talk about ...
Gastrulation asked 3/5, 2014 at 4:21
1
Solved
I have an assignment I'm working on and I'm having difficulty finishing it. The idea is to write a program if.c that executes one program and if that succeeds it executes the second program. I'm su...
1
Solved
I'm taking an operating systems course and I'm having a hard time how input is redirected with dup2 when you have forks. I wrote this small program to try and get a sense for it but I wasn't succes...
1
Solved
This is a follow up question from here.
Where I want do go
I would like to be able to temporarily redirect the stdout into a temp file, while python still is able to print to stdout. This would in...
Tswana asked 11/1, 2012 at 10:50
3
Solved
This is a follow up question from here specifically concerning its answer.
From a python module I am calling a Hello World executable that simply prints Hello World to the stdout. I am intereste...
Copaiba asked 10/1, 2012 at 14:32
2
Solved
My program calls library functions which print to stderr. I want to intervene so that all write calls to file descriptor #2 will instead get sent to somewhere else.
Here is my first attempt:
bool...
2
How do I use dup2 to perform the following command?
ls -al | grep alpha | more
6
Solved
Here's my code:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <wait.h>
#include <readline/readline.h>
#define NUMPIPES 2
int main(int argc, ch...
1
© 2022 - 2024 — McMap. All rights reserved.