New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hugo server keeps running after CTRL+C #3902

Closed
math2001 opened this Issue Sep 24, 2017 · 8 comments

Comments

Projects
None yet
8 participants
@math2001
Copy link

math2001 commented Sep 24, 2017

Hi!

I'm on windows 10. When I run hugo server, ctrl+c seems to stop the program in the terminal, but I actually have to kill it in the Task Manager, because it keeps serving. If I run hugo server again, it serves on a different port (because the normal one is busy).

Would there be a way to actually stop hugo's server when pressing ctrl+c?

@patheticpat

This comment has been minimized.

Copy link

patheticpat commented Oct 1, 2017

I'm not able to reproduce this. Can you provide more information on how to trigger this behavior?

@math2001

This comment has been minimized.

Copy link

math2001 commented Oct 1, 2017

Yep, and I'm pretty sure I found the reason of this bug:

I'm on Windows 10, so I have the the windows version of hugo. But I run it from Bash On Windows. So, I guess it sends a Linux signal for ctrl+c to hugo, which is interpreded as a Windows one.

If I run hugo from the actual cmd, there isn't any problem...

So, I you don't think there is something you can do about it, feel free to close this issue, I'm not sure it's a bug about hugo...

@moorereason moorereason closed this Oct 2, 2017

@MattSurabian

This comment has been minimized.

Copy link

MattSurabian commented Oct 23, 2017

Just noting that I also experience this bug on Linux in the Intellij Idea integrated terminal. It does not occur in my normal OS terminal. If I can, I'll try to figure out the reason and submit a PR for a fix.

While the cause definitely seems to be a less than ideal terminal setup regardless of OS there are other processes that do respect ctrl+c in the same non-optimal environment so ideally hugo serve should too.

@MattSurabian

This comment has been minimized.

Copy link

MattSurabian commented Oct 23, 2017

My system supports the following signals:

matt$ kill -l
 1) SIGHUP	 2) SIGINT	 3) SIGQUIT	 4) SIGILL	 5) SIGTRAP
 6) SIGABRT	 7) SIGBUS	 8) SIGFPE	 9) SIGKILL	10) SIGUSR1
11) SIGSEGV	12) SIGUSR2	13) SIGPIPE	14) SIGALRM	15) SIGTERM
16) SIGSTKFLT	17) SIGCHLD	18) SIGCONT	19) SIGSTOP	20) SIGTSTP
21) SIGTTIN	22) SIGTTOU	23) SIGURG	24) SIGXCPU	25) SIGXFSZ
26) SIGVTALRM	27) SIGPROF	28) SIGWINCH	29) SIGIO	30) SIGPWR
31) SIGSYS	34) SIGRTMIN	35) SIGRTMIN+1	36) SIGRTMIN+2	37) SIGRTMIN+3
38) SIGRTMIN+4	39) SIGRTMIN+5	40) SIGRTMIN+6	41) SIGRTMIN+7	42) SIGRTMIN+8
43) SIGRTMIN+9	44) SIGRTMIN+10	45) SIGRTMIN+11	46) SIGRTMIN+12	47) SIGRTMIN+13
48) SIGRTMIN+14	49) SIGRTMIN+15	50) SIGRTMAX-14	51) SIGRTMAX-13	52) SIGRTMAX-12
53) SIGRTMAX-11	54) SIGRTMAX-10	55) SIGRTMAX-9	56) SIGRTMAX-8	57) SIGRTMAX-7
58) SIGRTMAX-6	59) SIGRTMAX-5	60) SIGRTMAX-4	61) SIGRTMAX-3	62) SIGRTMAX-2
63) SIGRTMAX-1	64) SIGRTMAX	

I ran this script:

#!/bin/bash

SIGNALS=$(kill -l | grep -w -o "\S\+" | grep -v ")" | tr '\n' ' ')
trap_with_arg() {
    func="$1" ; shift
    for sig ; do
        trap "$func $sig" "$sig"
    done
}

func_trap() {
    echo Trapped: $1
}

trap_with_arg func_trap $SIGNALS
read # Wait so the script doesn't exit.

and learned that my OS terminal is actually sending SIGINT (signal 2) but the intellij integrated terminal sends NOTHING. So yeah. Hopefully this script can help someone else debug this issue, definitely nothing Hugo can do about it in my case anyway as it's a re-occurring bug in the idea terminal.

@johnzzhang

This comment has been minimized.

Copy link

johnzzhang commented Dec 25, 2017

I have the same issue on Windows 10 using bash on cygwin. To get around this I just launch the hugo server from a script that goes and kills all hugo.exe instances after I quit.

@ecow

This comment has been minimized.

Copy link

ecow commented Jan 24, 2018

Same problem using git bash on windows 10. The problem was not present with v 0.30. Appeared after an hugo reinstallation.

@guzey

This comment has been minimized.

Copy link

guzey commented May 1, 2018

Same problem for me. I also use git bash on windows 10 and CTRL+C does not stop the server. I'm running v0.38.2

@MattSurabian

This comment has been minimized.

Copy link

MattSurabian commented May 1, 2018

Have you tried running the script I posted above and hitting ctrl+c? Can you confirm what signal your terminal is sending if any?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment