Shutting down a JupyterLab Server with a single KeyboardInterrupt

Hi all, first post!

A feature that I’d really like in JupyterLab is: a flag to shutdown a JupyterLab Server with a single KeyboardInterrupt/SIGINT/^C. I’m really not sure why this isn’t already a feature.

Here’s an example of a workaround (this may not be the optimal solution):

import os
import atexit
import signal
import jupyterlab.labapp

def main():
   pid = os.fork()
   if pid == 0:
           atexit.register(os.kill, os.getppid(), signal.SIGINT)
       except KeyboardInterrupt:


Summary of code: Both processes receive a KeyboardInterrupt/SIGINT/^C. This causes the JupyterLab Server to receive its’ first KeyboardInterrupt/SIGINT/^C and the atexit function to send another SIGINT to the JupyterLab Server.

Since the JupyterLab Server shuts down with 2 KeyboardInterrupts/SIGINTs/^Cs, this method works.