Edgewall Software
Modify

Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#9467 closed defect (fixed)

Can't kill tracd with CTRL-C (or SIGTERM)

Reported by: davidbarnett2@… 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 Christian Boos, 14 years ago

Keywords: needinfo added

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?)

comment:2 by anonymous, 14 years ago

I confirm - Ctrl+C can't kill Trac 0.12 after default installation of openSUSE+Yakuake console.

comment:3 by derek@…, 14 years ago

… same problem on Centos 5.

comment:4 by roy@…, 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 roy@…, 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 jaroslav.benkovsky@…, 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

Last edited 14 years ago by Christian Boos (previous) (diff)

comment:7 by fcorreia@…, 14 years ago

Cc: fcorreia@… added

comment:8 by Jun Omae, 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):  
    9090
    9191
    9292class TracHTTPServer(ThreadingMixIn, WSGIServer):
     93    daemon_threads = True
    9394
    9495    def __init__(self, server_address, application, env_parent_dir, env_paths,
    9596                 use_http_11=False):

comment:9 by Christian Boos, 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).

in reply to:  9 comment:10 by Christian Boos, 14 years ago

Replying to cboos:

Are you sure about daemon_threads? 16.2.1. Thread Objects talks about the daemon property.

Sorry, just looked closer. That was for Thread objects, and we're in a SocketServer (20.17).

in reply to:  8 ; comment:11 by Remy Blank, 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.

in reply to:  11 ; comment:12 by Christian Boos, 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.

in reply to:  12 comment:13 by Jun Omae, 14 years ago

Milestone: 0.12.2
Resolution: fixed
Status: newclosed

Replying to cboos:

Just to be sure, I also verified that the patch doesn't affect the -r behavior.

Thanks, Christian!

Committed in [10436].

comment:14 by Remy Blank, 14 years ago

Owner: set to Jun Omae

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jun Omae.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Jun Omae to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.