question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SIGINT is sent twice when pressing Ctrl-C, causing dirty shutdown

See original GitHub issue

I have a package.json with the following scripts:

…
"startemulators": "firebase emulators:start --import seed",
"listen": "onchange 'source_files/*.js' -- touch functions/index.js",
"emulate": "concurrently \"npm run startemulators\" \"npm run listen\""
…

Running the emulate script works as expected, but pressing Ctrl-C to shut the processes down gives me this:

[0] i  emulators: Received SIGINT (Ctrl-C) for the first time. Starting a clean shutdown.
[0] i  emulators: Please wait for a clean shutdown or send the SIGINT (Ctrl-C) signal again to stop right now.
[0] i  emulators: Shutting down emulators.
[0] i  ui: Stopping Emulator UI
[0] ⚠  Emulator UI has exited upon receiving signal: SIGINT
[0] i  functions: Stopping Functions Emulator
[0] i  hosting: Stopping Hosting Emulator
[0] i  database: Stopping Database Emulator
[1] npm run listen exited with code 0
[0]  
[0] ⚠  emulators: Received SIGINT (Ctrl-C) 2 times. You have forced the Emulator Suite to exit without waiting for 3 subprocesses to finish.

So for some reason, a second SIGINT is sent to the firebase command specified in the first script. How come?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:8
  • Comments:18 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
samtsterncommented, Dec 2, 2021

Running into this problem myself, here’s a bit from my package.json:

  "scripts": {
    "build": "tsc",
    "build:watch": "tsc -w",
    "format": "prettier --write src/**/*.ts",
    "emulate": "firebase emulators:start --import=./emulator-data --export-on-exit",
    "serve": "concurrently 'npm run build:watch' 'npm run emulate'"
  },

If I run npm run serve and then press Ctrl+C the Firebase emulators see double SIGINT signals and shutdown without exporting data.

4reactions
ghivertcommented, Aug 12, 2022

Hi,

I have the same problem and investigated a little bit. By commenting out that line, I ended up with something working correctly, no double SIGINT, everything is cool.

It looks like spawn-command does not spawn the subprocess in detached mode, and it seems the defaults in concurrently are not setting detached options neither. Because if not, it’s perfectly normal to have the SIGINT sent twice, because it’s received by the subprocess, and then resent with command.kill(signal) a second time.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why should SIGINT be triggered twice to work as expected?
First Ctrl-C sends SIGINT to process, your program has a callback 'handler' for SIGINT processing, so your program won't quit.
Read more >
why would typing Ctrl+c twice stop a running process in Linux?
If a second Ctrl + C doesn't kill the program, try Ctrl + \ , which sends SIGQUIT, a more violent (but still...
Read more >
Chapter 2 - Sockets and Patterns - ZeroMQ guide
You can then send the message twice (or more, if you create more copies) and the message will only be finally destroyed when...
Read more >
virsh - management user interface - manpages.ubuntu!
Most virsh commands act synchronously, except maybe shutdown, setvcpus and setmem. ... Another option is to send SIGINT (usually with "Ctrl-C") to the...
Read more >
Cisco IOS Configuration Fundamentals Command Reference
To configure the default frequency time to scan modem signals, ... error code 0 sending SHUTDOWN FDIAG_QUIT to fdiag in slot 3 Board...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found