Date: Tue, 5 Mar 2002 08:51:41 +0100 From: Cliff Sarginson <csfbsd@raggedclown.net> To: FreeBSD Questions <questions@FreeBSD.org> Subject: Re: Cannot change X screen resolution Message-ID: <20020305075141.GA10395@raggedclown.net> In-Reply-To: <E16i7Dw-0004ko-00@hawk.mail.pas.earthlink.net> References: <20020305120749.B64582@wantadilla.lemis.com> <20020304222820.N96680-100000@earl-grey.cloud9.net> <20020305141610.E64582@wantadilla.lemis.com> <E16i7Dw-0004ko-00@hawk.mail.pas.earthlink.net>
index | next in thread | previous in thread | raw e-mail
On Mon, Mar 04, 2002 at 11:10:18PM -0600, Bob Giesen wrote:
> > > Question, how *DO* you capture the output of the X startup?
> >
> > $ startx 2>&1 > /var/tmp/startuplog
>
> In redirection, order is important. The above command will send
> stderr output (file descriptor "2") to the console (not to the
> logfile), which is where stdout (file descriptor "1") is going at the
> time the stderr redirection is evaluated.
> If you want errors logged and want to use the stdout-address
> shorthand ("2>&1," rather than typing out a logfile pathname twice),
> you must redirect stderr after redirecting stdout:
>
> $ startx >/var/tmp/startuplog 2>&1
>
> Bob
>
> P.S. If you're curious about what the programmers deemed standard
> output verus error-class messages (which is sometimes subjective),
> you could, of course, use separate filenames for error messages and
> standard output, e.g.:
>
> $ startx 2>/var/tmp/startuperrorlog >/var/tmp/startuplog
>
OT but...
If you are a new "C" programmer you might also be moderately curious to
run the following two short programs, guessing first what you expect to
happen, and then seeing what does happen.
#include <stdio.h>
main()
{
int i = 100;
while(i--) {
fprintf(stderr,"a"); /* write to stderr */
printf("b"); /* write to stdout without a newline */
}
}
#include <stdio.h>
main()
{
int i = 100;
while(i--) {
fprintf(stderr,"a"); /* write to stderr */
printf("b\n"); /* write to stdout with a newline */
}
}
It's left as an exercise for the reader to work out what is happening, and
how to "cure" it, and maybe explain a good reason for it (there is one) :)
--
Regards
Cliff Sarginson -- <csfbsd@raggedclown.net>
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020305075141.GA10395>
