redirecting stderr/stdout AFTER a program has been started
Mike Reinehr
cmr
Thu Oct 20 12:41:26 PDT 2005
On Thursday 20 October 2005 11:21 am, Roger Oberholtzer wrote:
> 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.
>
Point taken!
cmr
--
Debian 'Sarge': Registered Linux User #241964
"More laws, less justice." -- Marcus Tullius Ciceroca, 42 BC
More information about the Linux-users
mailing list