I've got a process that is currently running (arserverd) that was started by user "remedy". I am able to log in as this user. I would like to capture stderr and stdout without restarting the process. Is this possible?
I don't think so but you can try to read from /proc/PID/fd/1
for stdout and /proc/PID/fd/2
for stderr (replace PID
with the PID of the process).
If the process is already running, you could use the truss
command to intercept writes to file descriptor 1 or 2:
truss -w 1,2 -p pid_of_arserverd
Truss will output lines like
write(1, " m e s s a g e\n", 8) = 8
Truss is specific to Solaris. On linux systems, look for strace
instead.
Truss will slow down the process that you're trussing somewhat, so it's not something you'd want to use all the time. If you're looking for a permanent solution, your best bet is probably to redirect stdout and stderr to a file when launching the program. You can regularly truncate the file to keep its size manageable. An alternate is to run the program within a screen
session that you can reconnect to when you want to interact with the program.