redirecting stderr/stdout AFTER a program has been started
Roger Oberholtzer
roger
Thu Oct 20 10:32:07 PDT 2005
On Thu, 2005-10-20 at 17:49, Mike Reinehr wrote:
> On Thursday 20 October 2005 10:24 am, Roger Oberholtzer wrote:
> > On Thu, 2005-10-20 at 15:38, Man-wai Chang wrote:
> > > Can it be done?
> >
> > I doubt it. Unless the program is written to intercept, say, a signal,
> > that somehow communicates to it that the change is wanted. The main
> > problem is that some I/O to the file is buffered in the program.
> > Changing this without the program's knowledge would surely lead to
> > corruption. Hence, a signal that lets the program know this and be a
> > part of the change would be needed.
> >
>
> I'm really sticking my neck out, here, as I really don't know what I'm
> talking about, but I don't think this is correct. In fact, I don't think the
> program knows or cares where the output is directed. The program just is
> writing to the standard output & the standard error channels. It's the o/s
> that is directing the output to a terminal, file, pipe, etc.
>
> Now, whether the o/s can be instructed to redirect the output once the
> program is up & running, I don't know, but if it can be done, it should be
> documented in `man bash`.
stdin and all are no different from any other file. It is just that
these get attached to the first three descriptors without the program
doing anything. But they have all the very same properties as files
opened explicitly by the program. The OS simply cannot know that a
program has something buffered for a file. And by 'program', this
includes all the stuff libc is happily doing on your program's behalf.
So, I stand by my statement. Without active coordination with the
application itself, this will not work.
>
> cmr
+????????????????????????????+???????????????????????????????+
? Roger Oberholtzer ? E-mail: roger at opq.se ?
? OPQ Systems AB ? WWW: http://www.opq.se/ ?
? Kapellgr?nd 7 ? ?
? P. O. Box 4205 ? Phone: Int + 46 8 314223 ?
? 102 65 Stockholm ? Mobile: Int + 46 733 621657 ?
? Sweden ? Fax: Int + 46 8 314223 ?
+????????????????????????????+???????????????????????????????+
More information about the Linux-users
mailing list