View topic - exec reopen
exec reopen
4 posts
• Page 1 of 1
exec reopen
Hi,
I am trying to redirect th console during my c program execution using:
swawnlp(P_WAIT,"reopen","reopen","/dev/myNewConsole");
/dev/myNewConsole exists and I can sucessfully do:
reopen /dev/myNewConsole from the commandline.
any ideas
I am trying to redirect th console during my c program execution using:
swawnlp(P_WAIT,"reopen","reopen","/dev/myNewConsole");
/dev/myNewConsole exists and I can sucessfully do:
reopen /dev/myNewConsole from the commandline.
any ideas

- ddread
- New Member
- Posts: 3
- Joined: Sat Nov 16, 2002 2:00 am
That isn't how to do it.
first, reopen isn't a shell utility, it is a shell built-in and so you can't use it like you are trying to use it. Secondly, it reopen's the current shell's FD's and not the parent processes.
You want to look into using dup2(). Something like this:
int newout;
newout = open( "/dev/MyConsole", O_RDONLY );
dup2( newout, fileno( stdout ) );
For each input/output/error stream you want to change.
You want to look into using dup2(). Something like this:
int newout;
newout = open( "/dev/MyConsole", O_RDONLY );
dup2( newout, fileno( stdout ) );
For each input/output/error stream you want to change.
- cdm
- QNX Master
- Posts: 789
- Joined: Fri Jul 05, 2002 9:38 am
Thanks CDM.
I tried:
but no luck.
the open and dups return no errors but the console does not change.
I tried:
- Code: Select all
newout = open( "/dev/MyConsole", O_RDWR );
dup2( newout, fileno( stdout ));
dup2( newout, fileno( stdin ));
dup2( newout, fileno( stderr ));
but no luck.
the open and dups return no errors but the console does not change.
- ddread
- New Member
- Posts: 3
- Joined: Sat Nov 16, 2002 2:00 am
Sample Code
http://qnx.wox.org/qnx/sources/conout.c
qcc -o conout conout.c
./conout /dev/con1
I have test it on my consoles, on my serial ports and even over
qnet to a tty session running on my iPaq! Works just great.
Hope this helps you out.
qcc -o conout conout.c
./conout /dev/con1
I have test it on my consoles, on my serial ports and even over
qnet to a tty session running on my iPaq! Works just great.
Hope this helps you out.
- cdm
- QNX Master
- Posts: 789
- Joined: Fri Jul 05, 2002 9:38 am
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 2 guests