HELP - Redirect output of already running process?
Patrick R. McManus
mcmanus at ducksong.com
Wed Jun 5 17:18:11 EDT 2002
[John Abreau: Wed, Jun 05, 2002 at 04:58:18PM -0400]
>
> You said "under some circumstances"; can you expand on that? When
> would it *not* work?
>
a couple things come to mind:
* freopen(stdout) will update both stdout and fd=1 for you, but if
you've done something like p=stdout, [.. freopen (stdout).. ]
fwrite(p), you're sol. That's a weird thing to do, but you might
unwittingly make a copy of it on a function stack that takes a FILE
* as an arg, or tucked it away in a structure somewhere..
* this has nothing to do with freopen() but various mixtures of
kernels, glibc, and gdb refuse to allow mulitthreaded programs to
continue to run after you detach. Getting this right is sometimes
like casino night.
and of course the general disclaimer that programs are just state
machines - so attaching with gdb and generating transitions that the
programmer didn't consider is just pretty darn undefined. But when
your're desparate, you're desparate!
-P
More information about the Discuss
mailing list