分享

Dupx

 sven_ 2013-08-19

Dupx

Dupx is a simple *nix utility to redirect standard output/input/error of an already running process.

Motivation

I've often found myself in a situation where a process I started on a remote system via SSH takes much longer than I had anticipated. I need to break the SSH connection, but if I do so, the process will die if it tries to write something on stdout/error of a broken pipe. I wish I could suspend the process with ^Z and then do a
    bg %1 >/tmp/stdout 2>/tmp/stderr 
Unfortunately this will not work (in shells I know).

Output redirection of a running process

If you're familiar with dup(2) *nix system call, you know that if you issue it from the process space to an open file, you can remap any file descriptor to a new file and all subsequent calls to read/write(2) will read/write from/to the file. Thus the simple idea behind dupx is to use gdb to attach to the process and then do a dup(2) call on its file descriptors.

Implementation

Dupx is currently implemented as a simple shell script that drives GDB.

Compatibility

Dupx has been tested on Fedora systems.

Files and downloads



Last Modified: Mon Aug 16 15:46:00 PDT 2010

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多