-
Notifications
You must be signed in to change notification settings - Fork 61
Description
Hi all,
The Dropbox daemon writes incorrect PID to ~/.dropbox/dropbox.pid when running as systemd user service, here are some more details.
Environment
- OS: Linux
- Dropbox daemon version: 178.3.4678
- Dropbox command-line interface version: 2020.03.04
- Setup: Dropbox daemon running as systemd user service, interacting via nautilus-dropbox
The Dropbox daemon is writing an incorrect PID (2, which corresponds to the kthreadd kernel process) to ~/.dropbox/dropbox.pid when running as a systemd user service. This causes the dropbox status command to report "Dropbox isn't running!" even though the daemon is actually running properly.
Steps to Reproduce
- Run Dropbox daemon as a systemd user service
- Execute
dropbox status - Observe "Dropbox isn't running!" error message
- Check
cat ~/.dropbox/dropbox.pid- shows2instead of the actual daemon PID
The dropbox.pid file should contain the actual PID of the Dropbox daemon process, allowing dropbox status to correctly detect that the daemon is running.
Current Workaround
Manually updating the PID file with the correct value works:
systemctl show -p MainPID --value dropbox.service > ~/.dropbox/dropbox.pidAfter this manual fix, dropbox status works correctly.
The issue appears to be in how the daemon writes its PID when launched via systemd. The status check logic in nautilus-dropbox/dropbox.in lines 136-147 is working correctly:
def is_dropbox_running():
pidfile = os.path.expanduser("~/.dropbox/dropbox.pid")
try:
with open(pidfile, "r") as f:
pid = int(f.read())
with open("/proc/%d/cmdline" % pid, "r") as f:
cmdline = f.read().lower()
except:
cmdline = ""
return "dropbox" in cmdlineThe problem is that the daemon is writing 2 (kthreadd PID) to the file instead of its own PID.
Attempted Solutions
I tried using a systemd ExecStartPost directive to automatically correct the PID file:
ExecStartPost = "/bin/bash -c 'systemctl show -p MainPID --value dropbox.service > $HOME/.dropbox/dropbox.pid'"However, this doesn't work - the PID file still contains 2 after service startup, suggesting the daemon overwrites the file after the ExecStartPost runs.