Can background process access to stdout,stderr


 
Thread Tools Search this Thread
Operating Systems Linux Can background process access to stdout,stderr
# 1  
Old 08-04-2009
Lightbulb Can background process access to stdout,stderr

Hi folks Smilie

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.
# 2  
Old 08-04-2009
Yes, they can. A background process inherits its parents file descriptors, but there's no guarantee on where they're pointing to, or even if they're open.

Generally it's a good idea for a daemon to close stdin/stdout/stderr, and print messages to a log (either via syslog() or directly)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

stdout, stderr redirection

Hi all, can someone help me with the next redirection? i want to redirect the stdout+stderr of a command to the same file (this i can do by prog &> file) but in addition i want to redirect only the stderr to a different file. how can i do this please? (in BASH) thanks. (4 Replies)
Discussion started by: eee
4 Replies

2. Shell Programming and Scripting

stderr/stdout

Can somebody explain to me why the diff output is not going to stderr? Yet when I issue a diff from the command line the return code is -ne 1. I am guessing diff always writes to stdout??? Is there away I can force the difff to write to stderr USING THE CURRENT template. If possible, I... (5 Replies)
Discussion started by: BeefStu
5 Replies

3. Red Hat

Make STDERR readable as STDOUT

Hi all. I am trying to use backticks in Perl to put STDERR into a string. The code is... $readkey_test = `perl -MTerm::ReadKey -e 1`; print $readkey_test; if ($readkey_test =~ m/]/) { print "ReadKey not installed...\n"; } else { print "ReadKey installed...\n"; } If it comes up... (3 Replies)
Discussion started by: austinharris43
3 Replies

4. Shell Programming and Scripting

How to use tee with stdout and stderr?

I have been doing this: make xyz &> xyz.log &; tail -f xyz.log The problem with this is that you never can ge sure when "make xyz" is done. How can I pipe both stderr and stdout into tee so both stderr and stdout are copied both to the display and to the log file? Thanks, Siegfried (3 Replies)
Discussion started by: siegfried
3 Replies

5. 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

6. 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

7. Shell Programming and Scripting

precedence of stderr and stdout

#!/usr/bin/perl open(STDOUT, ">>$Textfile") open(STDERR, ">>$Textfile") print "program running\n"; $final = join("+", $initial,$final) #5 close (STDOUT); close (STDERR);Hi all, above is my perl code. Notice i have captured the stdout and stderr to the same textfile. my code is expected to... (1 Reply)
Discussion started by: new2ss
1 Replies

8. Programming

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... (3 Replies)
Discussion started by: matrixmadhan
3 Replies

9. Shell Programming and Scripting

STDOUT and STDERR going to a system log

We are running HP UNIX 11.0, and a patch applied 6 months ago. Ever since the patch, any scripts that run as script_name 1>&2 will write all the output to our /etc/cmcluster/package_name/package_cntl.log which is owned by root (the permission of the log file is -rwxr----- root sys) Does... (1 Reply)
Discussion started by: longyie904
1 Replies

10. Shell Programming and Scripting

Redirect stdout and stderr

How can I redirect and append stdout and stderr to a file when using cron? Here is my crontab file: */5 * * * * /dir/php /dir/process_fns.php >>& /dir/dump.txt Cron gives me an 'unexpected character found in line' when trying to add my crontab file. Regards, Zach Curtis POPULUS (8 Replies)
Discussion started by: zcurtis
8 Replies
Login or Register to Ask a Question