3

I've downloaded the BitTorrent Sync binary. The program only provides a Web UI interface. I'm trying to create a window for the daemon, using a terminal emulator, because I don't need an always online btsync. When I execute:

cd ~/.btsync/; konsole -e "./btsync --nodaemon"

the btsync daemon EXITS when i CLOSE the konsole window clicking the X button. When I run:

cd ~/.btsync/; uxterm -e "./btsync --nodaemon"

the xterm window STILL RUNS when I click the window close button. When I execute:

cd ~/.btsync/; urxvt -e "./btsync --nodaemon"

and I close the rxvt window, the btsync DAEMON STILL RUNS in background.

I was trying to use urxvt to assign an icon and a title to the "daemon window" and my only solution was execute this script:

#!/bin/sh
cd ~/.btsync/
echo BitTorrent Sync Web UI: http://127.0.0.1:8888/gui/en/index.html
echo
exec ~/.btsync/btsync --log ~/.btsync/sync.log --nodaemon

using this command line in a .desktop file:

Exec=/usr/bin/urxvt -fn "xft:Inconsolata" -icon ~/.btsync/btsync.png -iconic -title "BitTorrent Sync" -e btsync; /bin/kill $(cat ~/.btsync/.sync/sync.pid)

using /bin/kill to close the daemon when the rxvt window closes. My question is: somebody knows why konsole, xterm, rxvt doesn't share the same behavior in this case? I can't use x-terminal-emulator to generalize my code for this reason, and I have multiple clients with different Linux desktop environments in use.

1 Answer 1

2

The exit upon terminal close is caused by one of two things:

  1. Getting an EOF on stdin
  2. Receiving a SIGHUP

In my testing, both xterm and konsole do this, so its unclear why the behavior would differ, unless you're getting randomly broken signals from a recent (though now fixed) nVidia bug (see After upgrade, X button in titlebar no longer closes xterm).

You could use nohup to make sure neither exit.

I will note, however, that the -e syntax various between terminal emulators. For example, konsole -e 'sleep 60' will exit immediately; xterm -e 'sleep 60' will wait 60 seconds. If you remove the quote marks—passing each argument as a separate argument—it'll work in both terminals.

$ konsole -e sleep 60    # works
$ xterm -e sleep 60      # works
$ konsole -e 'sleep 60'  # FAILS
$ xterm -e 'sleep 60'    # works

Strictly speaking, Debian Policy says x-terminal-emulator -e must work like it does in xterm, but then specifies a behavior that xterm had at one point (it'd fail in that final case)... but xterm changed its behavior. See Debian Bug 648271, 11.8.3 "Packages providing a terminal emulator" says xterm passes -e option straight to exec.

So, it may simply be that you're using -e wrong; you should be doing:

cd ~/.btsync/; konsole -e ./btsync --nodaemon

Note the lack of quotes.

1
  • Thanks for your time. Your answer was useful. Thanks. Seems that the propietary btsync is the problem because doesn't process SIGHUP.
    – 1e100
    Mar 31, 2014 at 16:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .