Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect stdout/stderr of the executed command when running as foreground #16

Open
dhanjit opened this issue Nov 2, 2018 · 0 comments

Comments

@dhanjit
Copy link

dhanjit commented Nov 2, 2018

dtach -N /tmp/d1 echo "ASD" exits silently.

Let me explain an example where this is definitely a requirement. Consider the systemd unit as below:

[Unit]
Description=systemd integration for rtorrent using dtach - starts/stops rtorrent instances on startup/shutdown
Wants=network-online.target
After=network-online.target

[Service]
Environment="TERM=rxvt-unicode-256color"
KillMode=none
ExecStartPre=/usr/bin/mkdir -p %t/dtach
ExecStart=/usr/bin/dtach -N %t/dtach/rtorrent /usr/bin/rtorrent -n -o import=%E/rtorrent/.rtorrent.rc
ExecStop=/usr/bin/killall -u %u -w -s INT /usr/bin/rtorrent
# Refer https://github.com/crigler/dtach/issues/12, Success is error code 1
SuccessExitStatus=1

[Install]
WantedBy=default.target

Now what happens when rtorrent fails to start, say to due a config error? It prints to stderr/stdout. So will almost every cli program ranging from a simple echo to something heavy like rtorrent.

If I am running in foreground, then it would be prudent to redirect stdout/stderr of the command in question, or atleast have an option to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant