|
|
||||||
|
#1
|
|
|
|
|
Greetings,
I writing a fork-exec program as: if ((pid = fork()) == 0) { // Question here: how a redirect exec-ing process's output to a file? exec(); } else if (pid > 0) { // Wait for exec-ed process terminated. // Then read the output file. } Thanks in advance! Evan |
|
|
|
#2
|
|
|
|
|
In article <bkmf2p$ji4>, music4 wrote:
> Greetings, > > I writing a fork-exec program as: > > if ((pid = fork()) == 0) > { > // Question here: how a redirect exec-ing process's output to a file? int fd = open("filename",yourflags); dup2(fd,STDOUT_FILENO); cloes(fd); If I remember correctly.. Probably you can use 2 instead of STDOUT_FILENO. [..] |
|
#3
|
|
|
|
|
In article <slrnbmte9d.fto.noselasd>,
Nils O. Selåsdal <noselasd> wrote: >In article <bkmf2p$ji4>, music4 wrote: >> Greetings, >> >> I writing a fork-exec program as: >> >> if ((pid = fork()) == 0) >> { >> // Question here: how a redirect exec-ing process's output to a file? > int fd = open("filename",yourflags); > dup2(fd,STDOUT_FILENO); > cloes(fd); > >If I remember correctly.. Probably you can use 2 instead of STDOUT_FILENO. That wouldn't be a good idea, since 2 is stderr, not stdout. |
|
|
| Similar Threads | |
| redirect powershell stdout to objShell.Exec.Stdout.ReadAll()( Hi, I have a similar problem I am dealing with. Hence posting in this discussion chain. I have a powershell script text.ps1 And then I have a .js file which is invoking... |
|
| How to use fork-exec system call to redirect stdout/stderr to a buffer? Hi there I am a beginner for system programming, I'd like to use fork-exec programming to perform a "C-code compilation" and see if any compilation errors within... |
|
| Redirect STDOUT and STDERR to file in ksh First up, apologies if this is a really dumb question ("There are no dumb questions, but there are a lot of inquisitive idiots")... I'm running a perl script which just... |
|
| Any standard way to fork and exec something that isn't in a file? That subject probably sounds non-sensical--bear with me. Here's what I want to do. In one program I want to load a file into memory that has been encrypted; decrypt it; and... |
|
| Redirect stdout, stderr to file and stdout I have a small script that does some admin work for me. What I need to do now is not only have is display information to STDERR and STDOUT but also write the same... |
|
|
All times are GMT. The time now is 02:40 PM. | Privacy Policy
|