|
||||||
| C and C++ C and C++ forum for discussing all forms of C except for C#. These languages are powerful low level languages used for creating Operating Systems, Device Drivers, compilers and much more. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
I'm using some system calls in my code for example:
system ( "pr who.list" ); and instead of just printing it straight out to screen I want to redirect it to a file descriptor that I've set up that is a named pipe.... for example... 1. int newfd; 2. int old_state = dup ( (int)stdout ); 3. dup2 ( newfd, stdout ); 4. close (stdout ); 5. mknod ( "myfifo", S_IFIFO | 0666, 0 ); 6. newfd = open ( "myfifo", O_WRONLY ); 7. 8. system ( "pr who.list" ); 9. 10. dup2 ( old_state, stdout ); I thought line 2 would of done my redirection for me so that when 'pr' tries to write to stdout it will actually write to my file descriptor which another process will read and do something with, but I'm not getting anything from the pipe. It just returns to my command line until I exit the program and then it squirts it out to the screen... Last edited by BlueDream; 05-15-2008 at 11:30 AM. |
| Sponsored Links |
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|