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...
Levorotatory asked 7/10, 2010 at 17:15

3

Solved

I have to write a shell that can run pipes. For example commands like ls -l | wc -l". I have successfully parsed the command given by the user as below: "ls" = firstcmd "-l" = frsarg "wc" ...
Humpy asked 24/11, 2015 at 2:16

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...
Contrarious asked 22/10, 2011 at 18:12

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...
Selfinterest asked 19/2, 2016 at 23:28

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...
Pongee asked 8/6, 2015 at 16:19

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...
Gomez asked 13/2, 2013 at 5:11

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...
Pentalpha asked 14/1, 2012 at 7:46

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...
Heritor asked 23/2, 2011 at 19:12

2

How do I use dup2 to perform the following command? ls -al | grep alpha | more
Equalitarian asked 4/9, 2010 at 14:46

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...
Tepid asked 27/5, 2009 at 17:0
1

© 2022 - 2024 — McMap. All rights reserved.