stderr in background process


 
Thread Tools Search this Thread
Top Forums Programming stderr in background process
# 1  
Old 09-21-2005
stderr in background process

Herez the question,

In a process which writes into file FILE1 with descriptor
fHandler1 and it is run as a background process
where would statements be directed
when stderr descriptor is used.

fprintf(stderr,"some message\n");

assume that session from which it is run is terminated and later the above statement is executed.

Are there any chances for output given to stderr descriptor to be redirected
to the fHandler1...

because in one of our process, i could specifically see redirections are in a perplexed manner

fHandler1=fopen("ping.con","a");
fprintf(fHandler,"first segment\n);
fprintf(stderr,"errored value\n");

i am surprised to see the output errored value in the file ping.con

please let me know if i had to provide any more information.
# 2  
Old 09-21-2005
I put your code in a C program. Here it is:
Code:
#include<stdio.h>

int main(void) {

   FILE *fHandler1;

   fHandler1=fopen("ping.con","a");
   fprintf(fHandler1,"first segment\n");
   fprintf(stderr,"errored value\n");
   fclose(fHandler1);
}

This worked fine. When I ran it, ping.con was created and the line "first segment" was written in and the string "errored value" was output to the stderr (on screen).

Unless you are running the program as './program_name 2>>ping.con ' or assigning the value of fHandler1 to stderr at some point in the program, "errored value" should not be output to ping.con.
# 3  
Old 09-21-2005
thanks for the reply,

the code that u tried seems to work fine
this is what even i tried in my code and it worked perfectly
as expected

first message to be sent to file with fHandler
and the second to the stderr (stderr)

i am sure no where errors are redirected and file handlers
mishandled but still the problem exists

i would like to remind u, i am not sure whether there is any hint in that
the session from where the program is run would be terminated.

as in this sequence

program boots
string directed to file
session terminates
string directed to 2 stderr
processing continues


i dont see any acceptance with the scenario
but still problems faints to perish
and i am looking out for the reason.
# 4  
Old 09-22-2005
Does the file ping.com exist before the program opens it? Maybye it's a named pipe...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Make background process interact with fg process

Hi, I have written a menu driven shell script in which as per the choice, I run the another script on background. For eg: 1. get info 2)process info 3)modify info All the operations have different scripts which i schedule in background using &. However I wish to display the error... (0 Replies)
Discussion started by: ashima jain
0 Replies

2. Shell Programming and Scripting

How to put FTP process as a background process/job in perl?

Hi, I am using net::ftp for transferring files now i am trying in the same Linux server as a result ftp is very fast but if the server is other location (remote) then the file transferred will be time consuming. So i want try putting FTP part as a background process. I am unaware how to do... (5 Replies)
Discussion started by: vanitham
5 Replies

3. UNIX for Dummies Questions & Answers

Script to start background process and then kill process

What I need to learn is how to use a script that launches background processes, and then kills those processes as needed. The script successfully launches the script. But how do I check to see if the job exists before I kill it? I know my problem is mostly failure to understand parameter... (4 Replies)
Discussion started by: holocene
4 Replies

4. Shell Programming and Scripting

Can I pipe stderr to another process

Hi there, I was wondering if it was possible to pipe stderr to another process. I need to eval commands given as arguments and I would like to redirect stderr to another process. I can redirect stderr to a file like this... toto:~$ command="one=1" toto:~$ eval $command 2> error toto:~$... (5 Replies)
Discussion started by: chebarbudo
5 Replies

5. Shell Programming and Scripting

Background Process.

How to create a backgrond processes ? (5 Replies)
Discussion started by: anupdas
5 Replies

6. Linux

Can background process access to stdout,stderr

Hi folks :) Can deamonized process access to stderr, stdout? I 'm trying to display error_num/return value of a function run() in stderr using fprintf(stderr, "function run() returns = %d", ret_val); run() is called after deamonizing the process. (1 Reply)
Discussion started by: katty
1 Replies

7. Solaris

Handling Stdout&StdErr for background jobs.

Hello Friends, sorry, i am not very familiar with Unix programming. Could you please help me on this? We have to start different components from a startup script. each components are started as below in the background in a startprocess function $nohup $file $args >>$logFile 2>&1 & ... (1 Reply)
Discussion started by: alvinbush
1 Replies

8. Shell Programming and Scripting

Handling Stdout&StdErr for background jobs.

Hello Friends, sorry, i am not very familiar with Unix programming. Could you please help me on this? We have to start different components from a startup script. each components are started as below in the background in a startprocess function $nohup $file $args >>$logFile 2>&1 & ... (0 Replies)
Discussion started by: alvinbush
0 Replies

9. Programming

background process

I have made a shell that accept a command and parameters. It is working properly. I have tryed to implement background process in main(). But i dont know to implement them. Can anyone give me a lille example?? #include <stdlib.h> #include <stdio.h> #include <string.h> /* The following... (3 Replies)
Discussion started by: badshah
3 Replies

10. Shell Programming and Scripting

capture the process id when starting a background process

Hello all, How do I start a background process and save the process id to a file on my system. For example %wait 5 & will execute and print the process id. I can't figure out how to get it to a file. I've tried: > filename 0>filename 1>filename. Any assistance is most appreciated. Thanks, Jim... (10 Replies)
Discussion started by: jleavitt
10 Replies
Login or Register to Ask a Question