#9467 closed defect (fixed)
Can't kill tracd with CTRL-C (or SIGTERM)
Reported by: | Owned by: | Jun Omae | |
---|---|---|---|
Priority: | normal | Milestone: | 0.12.2 |
Component: | web frontend/tracd | Version: | 0.12 |
Severity: | normal | Keywords: | needinfo |
Cc: | fcorreia@… | Branch: | |
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
If I start up tracd like this:
tracd /path/to/project
and then hit it with the browser, I can't kill the process either by pressing CTRL-C or with kill -15 THE_PID
. I can kill the tracd process normally if I do it before the server handles any requests.
Attachments (0)
Change History (14)
comment:1 by , 14 years ago
Keywords: | needinfo added |
---|
comment:2 by , 14 years ago
I confirm - Ctrl+C can't kill Trac 0.12 after default installation of openSUSE+Yakuake console.
comment:4 by , 14 years ago
I'm seeing the same on my Ubuntu box (2.6.32.16-linode28 #1 SMP Sun Jul 25 21:32:42 UTC 2010 i686 GNU/Linux), python 2.6.5, mysql 5.1 backend.
This smells like the kind of behavior you get if you've spawned a thread and are waiting for it to exit.
comment:5 by , 14 years ago
Just to add some details, if I strace the tracd process, here's what I see when I Control-C it. The string of select() calls are the idle behavior before I hit Control-C.
[pid 8062] select(4, [3], [], [], {0, 500000}) = 0 (Timeout) [pid 8062] select(4, [3], [], [], {0, 500000}) = 0 (Timeout) [pid 8062] select(4, [3], [], [], {0, 500000}) = 0 (Timeout) [pid 8062] select(4, [3], [], [], {0, 500000}) = 0 (Timeout) [pid 8062] select(4, [3], [], [], {0, 500000}) = 0 (Timeout) [pid 8062] select(4, [3], [], [], {0, 500000}) = 0 (Timeout) [pid 8062] select(4, [3], [], [], {0, 500000}) = 0 (Timeout) [pid 8062] select(4, [3], [], [], {0, 500000}) = 0 (Timeout) [pid 8062] select(4, [3], [], [], {0, 500000}) = 0 (Timeout) [pid 8062] select(4, [3], [], [], {0, 500000}) = 0 (Timeout) [pid 8062] select(4, [3], [], [], {0, 500000}) = 0 (Timeout) [pid 8062] select(4, [3], [], [], {0, 500000}) = 0 (Timeout) [pid 8062] select(4, [3], [], [], {0, 500000}) = 0 (Timeout) [pid 8062] select(4, [3], [], [], {0, 500000}) = 0 (Timeout) [pid 8062] select(4, [3], [], [], {0, 500000}) = ? ERESTARTNOHAND (To be restarted) [pid 8062] --- SIGINT (Interrupt) @ 0 (0) --- [pid 8062] rt_sigaction(SIGINT, {0x810fde0, [], 0}, {0x810fde0, [], 0}, 8) = 0 [pid 8062] sigreturn() = ? (mask now []) [pid 8062] futex(0x923e398, FUTEX_WAIT_PRIVATE, 0, NULL
comment:6 by , 14 years ago
I have the same problem on Ubuntu 10.04, tracd is run gnome-terminal through ssh with
$ ssh server.example.com ... $ su - www-data -c "tracd --port 8000 /var/trac"
The tracd process ignores ^C, ^Z, sigterm and sigint (sent as root, of course). Annoying
comment:7 by , 14 years ago
Cc: | added |
---|
follow-up: 11 comment:8 by , 14 years ago
I have the same issue with 0.12-stable r10430. CTRL-C cannot stops tracd, however kill -TERM
works.
I tested with the following environments and the same issue happens.
- python 2.4.6 (Debian 5.0)
- python 2.5.4 and python 2.6.4 (Ubuntu 9.10)
- python 2.6.6 (Windows XP sp3)
In sending CTRL-C, I think that tracd waits the termination of worker threads TracHTTPServer
generates as a non-daemon thread.
In kill -TERM
, SIGTERM just kills the tracd process because tracd don't handle SIGTERM.
The worker thread should become a daemon thread.
-
trac/web/standalone.py
diff --git a/trac/web/standalone.py b/trac/web/standalone.py index 9e85c74..0d9d57c 100755
a b class TracEnvironMiddleware(object): 90 90 91 91 92 92 class TracHTTPServer(ThreadingMixIn, WSGIServer): 93 daemon_threads = True 93 94 94 95 def __init__(self, server_address, application, env_parent_dir, env_paths, 95 96 use_http_11=False):
follow-up: 10 comment:9 by , 14 years ago
Are you sure about daemon_threads
? 16.2.1. Thread Objects talks about the daemon
property.
Besides, how are you starting tracd
? When I do simply tracd -p 9001 test-env/
, I can interrupt it by ^C
without doing anything special (Python 2.5 or 2.7.1, on Linux 2.6.27-11-server x86_64 GNU/Linux).
^C
is mapped to intr
for you, right? (check with stty -a
).
comment:10 by , 14 years ago
Replying to cboos:
Are you sure about
daemon_threads
? 16.2.1. Thread Objects talks about thedaemon
property.
Sorry, just looked closer. That was for Thread
objects, and we're in a SocketServer
(20.17).
follow-up: 12 comment:11 by , 14 years ago
Replying to jomae:
The worker thread should become a daemon thread.
IIRC this could have a negative effect on the reload functionality.
follow-up: 13 comment:12 by , 14 years ago
Replying to rblank:
Replying to jomae:
The worker thread should become a daemon thread.
IIRC this could have a negative effect on the reload functionality.
That was #7049, and the trouble was with --daemon
option which a different thing (the process is set up as daemon process).
Now I was able to reproduce the original issue: if there are many threads or long running threads, I indeed can't interrupt tracd
right away.
The patch proposed in comment:8 fixes that. Well done, Jun!
Just to be sure, I also verified that the patch doesn't affect the -r
behavior.
comment:13 by , 14 years ago
Milestone: | → 0.12.2 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
comment:14 by , 14 years ago
Owner: | set to |
---|
At first this sounded familiar, as I thought I had experienced something similar on Windows recently. But I tested again and now it seems to work as expected.
I just tested on Linux (2.6.27-11-server x86_64 GNU/Linux lenny/sid) and interrupting tracd with a CTRL-C or kill -TERM works, with either plain tracd, or -r, or -d (well, obviously not CTRL-C in the latter case). This behavior is also highly dependent on your terminal settings (stty -a?)