Skip to content
This repository has been archived by the owner on Jun 4, 2022. It is now read-only.

SIGINT cannot be caught #191

Closed
metametadata opened this issue Jun 24, 2017 · 8 comments · Fixed by #400
Closed

SIGINT cannot be caught #191

metametadata opened this issue Jun 24, 2017 · 8 comments · Fixed by #400

Comments

@metametadata
Copy link

Here's a repo for reproducing the steps in Lumo and NodeJS. I've checked the behaviour on SIGINT, SIGTERM, SIGQUIT and SIGHUP and noticed the problem only with SIGINT.

Steps:

  1. Run Lumo app which listens to SIGINT signal: lumo app.cljs

  2. Send SIGINT (e.g. by clicking Ctrl+C or by executing kill -INT $!).

Actual: app exits without first catching signal event.

Expected: app is able to intercept a signal (because NodeJS apps are able to catch this signal).

This feature is important for apps needing to do some cleanup before exiting. E.g. I use signal-exit module to do cleanup.

@anmonteiro
Copy link
Owner

thanks for the report. this may be a consequence of adding the ability to kill infinite loops with ctrl+c (6b1b5a1).
We may have to run pending SIGINT handlers or something.

@anmonteiro
Copy link
Owner

anmonteiro commented Jun 25, 2017

@metametadata can you repro this on a Lumo version < 1.4, e.g. 1.2 or 1.3?

@metametadata
Copy link
Author

metametadata commented Jun 25, 2017

Yes, looks like a regression as it works in 1.3.0 as expected:

~/Dropbox/dev/lumo-signals (master ✘)✭ ᐅ lumo --version
1.5.0
~/Dropbox/dev/lumo-signals (master ✘)✭ ᐅ lumo app.cljs 
Hello
^C

~/Dropbox/dev/lumo-signals (master ✘)✭ ᐅ ./lumo --version
1.3.0
~/Dropbox/dev/lumo-signals (master ✘)✭ ᐅ ./lumo app.cljs 
Hello
^Csignal-exit: nil "SIGINT"

@anmonteiro
Copy link
Owner

Turns out this is actually fixed in master. Please reopen if still an issue.

@metametadata
Copy link
Author

Thank you, looking forward to the next release!

@metametadata
Copy link
Author

In v0.6.0 the issue is still reproducible, but only when some ns is required in the script. E.g.:

#!/usr/bin/env lumo
(ns core.app
  (:require [clojure.string :as str])  ; <--------- this line breaks catching of Ctrl+C
) 

(.log js/console "Hello")

(def on-exit (js/require "signal-exit"))
(on-exit (fn [code signal]
             (.log js/console "signal-exit:" (pr-str code) (pr-str signal))))

(js/setTimeout #(.log js/console "Bye")
               30000)

@anmonteiro anmonteiro reopened this Jul 4, 2017
@mnewt
Copy link

mnewt commented Dec 6, 2017

It looks like this issue is happening no matter what. I see the same behavior whether at the REPL or in a script. When ctrl-c is pressed, lumo exits without ever calling the SIGINT handler.

$ lumo --version
1.8.0-beta
$ node --version
v8.9.1
cljs.user=> (.on js/process "SIGINT" #(console.log "SIGINT received."))
#object[process [object process]]
cljs.user=> (loop [] (recur))
^C
<<<lumo exits with status code 130>>>

anmonteiro added a commit that referenced this issue May 13, 2018
anmonteiro added a commit that referenced this issue May 13, 2018
* ctrl-c during REPL execution exits lumo

fixes #327
fixes #191
@rhg
Copy link

rhg commented Aug 4, 2018

fwiw I'm still seeing this issue on 1.9.0-alpha.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants