08-27-2012
Quote:
Originally Posted by
DGPickett
It is wise to log debug stuff to stderr, which by default is completely unbuffered. Just change 'printf(' to 'fprintf( stderr,'.
It's also wise because it keeps your error messages separate from your data. If you're writing a PNG image to standard output, for instance, you don't want "Warning: Needed to flatten image" stuck randomly in the middle of that, you want that going where a human will read it or just nowhere. Writing to stderr lets you control it independently.
9 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,all!
Now ,I write perl for windows platform,and will use signal for asynchronous operations ,but I find it could bring some bugs if it is used incorrectly ,pls help!!! :D (1 Reply)
Discussion started by: hhh101
1 Replies
2. UNIX for Dummies Questions & Answers
Hi,
when I execute a script on unix AIX, I've got an error message:
"Execution: 85328 Signal d'alarme".
If I edit this file with "vi", I ve got the same error after a while (about 1 minute).
If I try with another user I still have the problem.
But if I rename this file, no problem.
My... (5 Replies)
Discussion started by: cgsteph
5 Replies
3. Shell Programming and Scripting
Who can explain the meaning of the &2 &1 or @, #, etc in the script?
Is there any document which can explain the usage of these words in details?
for example:
ls /etc/sysconfig/network > /dev/null 2>&1
#@
bash, ksh and sh.
Thanks in advance for ur advice. (1 Reply)
Discussion started by: GCTEII
1 Replies
4. Programming
I am using the signal function, and passing it a function named quit procedure...I get the following warning....
passing arg2 of signal from incompatible pointer type...
void quit_procedure(void); //this is the way i define my prototype...
signal(SIGINT, quit_procedure);
Please guide... (5 Replies)
Discussion started by: jacques83
5 Replies
5. Shell Programming and Scripting
Hi all
I have Master script, Main script ,and 4 Child script.
Master.sh
#!/bin/bash
/export/home/user/Main.shMain.sh
#!/bin/bash
/export/home/user/Child1.sh &
/export/home/user/Child2.sh &
/export/home/user/Child3.sh &
/export/home/user/Child4.sh &I run only Master.sh script... (1 Reply)
Discussion started by: almanto
1 Replies
6. UNIX for Dummies Questions & Answers
I have this code that doesnt do what it is suppose to do. It should block signal that I send while process is running. I press control+z while this process is running and it should be blocked but it isnt. When i press control+z it gives me this....
+ Stopped
When I change SIGTSP into SIGINT then... (5 Replies)
Discussion started by: joker40
5 Replies
7. UNIX for Advanced & Expert Users
Hi,
from my Windows Workstation I can connect with PUTTY to an AIX 6.1 unix server.
On AIX via PUTTY I run DBCA which has a grphical interface.
Then :
#DISPLAY=local_host:0.0 ; export DISPLAY
$(hostname) $(whoami):/appli/oracle/product/10.2.0/db_1/bin#dbca
_X11TransSocketINETConnect()... (12 Replies)
Discussion started by: big123456
12 Replies
8. Programming
A program have to receive signals and work agreed with it, but the process have to receive more than one signal when it is attending other. Those have to be queued to be attended later recived.
how can i do that?
thanks. (2 Replies)
Discussion started by: marmaster
2 Replies
9. Shell Programming and Scripting
Task 1:
#!/bin/ksh
if
then
echo "Usage : $0 Signalnumber PID"
exit
fi
case "$1" in
1) echo "Sending SIGHUP signal"
kill -SIGHUP $2
;;
2) echo "Sending SIGINT signal"
kill -SIGINT $2
;;
3) echo "Sending SIGQUIT signal"
kill -SIGQUIT $2 (3 Replies)
Discussion started by: Ramesh M
3 Replies
LEARN ABOUT REDHAT
stderr
STDIN(3) BSD Library Functions Manual STDIN(3)
NAME
stdin, stdout, stderr -- standard I/O streams
SYNOPSIS
#include <stdio.h>
extern FILE *stdin;
extern FILE *stdout;
extern FILE *stderr;
DESCRIPTION
Under normal circumstances every Unix program has three streams opened for it when it starts up, one for input, one for output, and one for
printing diagnostic or error messages. These are typically attached to the user's terminal (see tty(4)) but might instead refer to files or
other devices, depending on what the parent process chose to set up. (See also the ``Redirection'' section of sh(1) .)
The input stream is referred to as ``standard input''; the output stream is referred to as ``standard output''; and the error stream is
referred to as ``standard error''. These terms are abbreviated to form the symbols used to refer to these files, namely stdin, stdout, and
stderr.
Each of these symbols is a stdio(3) macro of type pointer to FILE, and can be used with functions like fprintf(3) or fread(3).
Since FILEs are a buffering wrapper around Unix file descriptors, the same underlying files may also be accessed using the raw Unix file
interface, that is, the functions like read(2) and lseek(2). The integer file descriptors associated with the streams stdin, stdout, and
stderr are 0, 1, and 2, respectively. The preprocessor symbols STDIN_FILENO, STDOUT_FILENO, and STDERR_FILENO are defined with these values
in <unistd.h>.
Note that mixing use of FILEs and raw file descriptors can produce unexpected results and should generally be avoided. (For the masochistic
among you: POSIX.1, section 8.2.3, describes in detail how this interaction is supposed to work.) A general rule is that file descriptors
are handled in the kernel, while stdio is just a library. This means for example, that after an exec, the child inherits all open file
descriptors, but all old streams have become inaccessible.
Since the symbols stdin, stdout, and stderr are specified to be macros, assigning to them is non-portable. The standard streams can be made
to refer to different files with help of the library function freopen(3), specially introduced to make it possible to reassign stdin, stdout,
and stderr. The standard streams are closed by a call to exit(3) and by normal program termination.
SEE ALSO
sh(1), csh(1), open(2), fopen(3), stdio(3)
CONSIDERATIONS
The stream stderr is unbuffered. The stream stdout is line-buffered when it points to a terminal. Partial lines will not appear until
fflush(3) or exit(3) is called, or a newline is printed. This can produce unexpected results, especially with debugging output. The buffer-
ing mode of the standard streams (or any other stream) can be changed using the setbuf(3) or setvbuf(3) call. Note that in case stdin is
associated with a terminal, there may also be input buffering in the terminal driver, entirely unrelated to stdio buffering. (Indeed, nor-
mally terminal input is line buffered in the kernel.) This kernel input handling can be modified using calls like tcsetattr(3); see also
stty(1), and termios(3).
CONFORMING TO
The stdin, stdout, and stderr macros conform to ANSI X3.159-1989 (``ANSI C89''), and this standard also stipulates that these three streams
shall be open at program startup.
Linux 2.0 March 24, 1998 Linux 2.0