Skip to content

Doesn't react to Ctrl-C when run in a subshell with -no-restart (Linux) #4774

Closed

Description

@calmh

When run in a subshell, on Linux, i.e.

jb@acro:~ $ cat run.sh 
#!/bin/bash

syncthing -no-browser -no-restart

jb@acro:~ $ ./run.sh 

Syncthing won't get and exit due to a Ctrl-C. If the last line is exec syncthing ... it's all good as then there is no intermediate shell.

Another workaround is to not use -no-restart, as the monitor process will then handle this correctly, getting the Ctrl-C and passing the signal to its child. And honestly this is the expected way to run when running "interactively" anyway.

This is due to the process group juggling in c554ffc, 91210cb, c2119c9. The controlling terminal sends the signal to the foreground process group, which in this case is just bash (as we move away into our own process group).

BSD, Mac, etc don't suffer from this as they have sane thread implementations where we don't need to do tricks with the process group.

A potential "fix" could be to have the monitor process do this instead, by using runtime.LockOSThread, setting the niceness for the current thread, then syscall.ForkExec to spawn the real syncthing from that thread, inheriting the priority. I'm not very fond of moving stuff into the monitor.

Or we could just remove the hack and tell Linux users to set the niceness themselves. Or maybe just let this be a known issue forever.

Activity

  1. added
    bug
    on Feb 25, 2018
  2. changed the title [-]Doesn't react to Ctrl-C when run in a subshell (Linux)[/-] [+]Doesn't react to Ctrl-C when run in a subshell with -no-restart (Linux)[/+] on Feb 25, 2018
  3. added 3 commits that reference this issue on Jan 19, 2020
    f2e49f9
    12b4bdd
    86ea10d
  4. added a commit that references this issue on Jan 20, 2020
    69da11a
  5. added a commit that references this issue on Jan 21, 2020
    7ee903a
  6. added this to the v1.4.0 milestone on Jan 24, 2020
  7. added 2 commits that reference this issue on Jan 30, 2020
    35caa6a
    32ba321
  8. added
    frozen-due-to-age
    on Jan 20, 2021
  9. locked and limited conversation to collaborators on Jan 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugfrozen-due-to-age

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions