开发者

capturing stderr and stdout from an already running process in solaris

开发者 https://www.devze.com 2022-12-08 04:19 出处:网络
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 开发者_J

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 开发者_JAVA百科process. Is this possible?


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.


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).

0

精彩评论

暂无评论...
验证码 换一张
取 消