Operating System - HP-UX
1753561 Members
5608 Online
108796 Solutions
New Discussion юеВ

How to get the output of a process from PID

 
Dash_2
Occasional Contributor

How to get the output of a process from PID

Hi,

I have started a process by redirecting its output to /dev/null. Is there any way to get the output into a file without stopping the process ? From the PID can I get the output ?

Any help ?
Thanks in advance.
Regards
Dash
7 REPLIES 7
James R. Ferguson
Acclaimed Contributor

Re: How to get the output of a process from PID

Hi Dash:

No.

Regards!

...JRF...
Pete Randall
Outstanding Contributor

Re: How to get the output of a process from PID

I'm afraid you'll have to kill it and restart it.


Pete

Pete
Dash_2
Occasional Contributor

Re: How to get the output of a process from PID

Thanks James and Pete.

SO that is the ONLY solution.

OldSchool
Honored Contributor

Re: How to get the output of a process from PID

"SO that is the ONLY solution. "


Are you asking or making an observation? If your asking, that IS the ONLY solution.

You might consider awarding points to James and Pete, as the answer is correct, even if undesired
whiteknight
Honored Contributor

Re: How to get the output of a process from PID


Dash

the output is going to /dev/null, so it is gone!

WK
please assign points
Problem never ends, you must know how to fix it
Bill Hassell
Honored Contributor

Re: How to get the output of a process from PID

Unless your process has been written to respond external changes (config files, signals), your process has already opened the file (/dev/null) and just keeps writing to the currently open file descriptor in the program. To change this file means that the program must close and release the file, then open a new file and continue writing. In other words, not possible.


Bill Hassell, sysadmin
Dennis Handly
Acclaimed Contributor

Re: How to get the output of a process from PID

How much is it worth to you?
You do know that the data written is gone, but you may be able to "redirect" future output.

>Bill: To change this file means that the program must close and release the file, then open a new file and continue writing. In other words, not possible.

That's not quite true. If you can attach gdb to the process you could do a command line call to fopen a file and then dup2 the FD to stdout.

Of course I'm waving my hands here but that process was what we did for cfront.