Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 523552 - net-misc/tor: send SIGINT during STOP
Summary: net-misc/tor: send SIGINT during STOP
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Anthony Basile
URL:
Whiteboard:
Keywords:
: 523554 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-09-23 19:31 UTC by Toralf Förster
Modified: 2014-12-23 17:27 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Toralf Förster gentoo-dev 2014-09-23 19:31:02 UTC
In https://trac.torproject.org/projects/tor/ticket/5525 this is mentioned for a graceful shutdown.

I see the use of this signal in the tor.service file, but not in tor.initd-r6. Or is the signal INT automatically send by the start-stop-daemon ?
Comment 1 Jeroen Roovers (RETIRED) gentoo-dev 2014-09-23 20:26:09 UTC
*** Bug 523554 has been marked as a duplicate of this bug. ***
Comment 2 Anthony Basile gentoo-dev 2014-09-23 23:16:19 UTC
I added two new options to init.d/tor for tor-0.2.5.8_rc-r1.  One is `graceful` which is a graceful restart (like apache's graceful) and the other is `gracefulstop` (also like apache).

But there appears to be a bug in openrc's start-stop-daemon.  After stopping the process with

start-stop-daemon -P --stop --signal INT -R ${GRACEFUL_TIMEOUT} --pidfile "${PIDFILE}" --exec /usr/bin/tor -- --PidFile "${PIDFILE}"

I get an exit code of 0 (as expected) but openrc marks the process as crashed.  I did try many variations on that command line with no joy.

I'm cc-ing the openrc people.
Comment 3 Toralf Förster gentoo-dev 2014-09-26 17:09:24 UTC
used it today after upgrade from 0.2.4.24 to 0.2.5.8-rc - works fine.
Thx.
Comment 4 Anthony Basile gentoo-dev 2014-09-27 07:49:33 UTC
(In reply to Toralf Förster from comment #3)
> used it today after upgrade from 0.2.4.24 to 0.2.5.8-rc - works fine.
> Thx.

gracefulstop stops the process correctly but openrc marks it as crashed.
Comment 5 Anthony Basile gentoo-dev 2014-10-09 11:26:02 UTC
ping @openrc peeps.  I think this is a bug in openrc.  Can you verify whether I'm not just being stupid here.  I'm pretty sure my initrd script at $PORTDIR/net-misc/tor/files/tor.initd-r7 is correctly written.  The behavior for "graceful" is as expected.  Yet for "gracefulstop" the daemon is marked "crashed."  tor is brought down gracefully with SIGINT but then openrc thinks the daemon has crashed.
Comment 6 Toralf Förster gentoo-dev 2014-10-10 15:47:55 UTC
There's a cosmetic thing in gracefulstop() of net-misc/tor:

It prints out dots in a line till tor is stopped. But now the cursor gets a carriage return (\r) but no newline (\n), so that the following command is printed over onto the line of dots.
Comment 7 Anthony Basile gentoo-dev 2014-12-20 00:56:24 UTC
(In reply to Toralf Förster from comment #6)
> There's a cosmetic thing in gracefulstop() of net-misc/tor:
> 
> It prints out dots in a line till tor is stopped. But now the cursor gets a
> carriage return (\r) but no newline (\n), so that the following command is
> printed over onto the line of dots.

Sorry I'm super busy and just now looking over old bugs.  Do you have a patch?
Comment 8 Toralf Förster gentoo-dev 2014-12-20 17:33:50 UTC
well, b/c the similar section in apache2's init script.d doesn't suffer from this rather cosmetic issue, what's about this quick&dirty solution :

gracefulstop() {
        ebegin "Gracefully stopping Tor"
    ebegin "This can take up to ${GRACEFUL_TIMEOUT} seconds"
    start-stop-daemon -P --stop --signal INT -R ${GRACEFUL_TIMEOUT} --pidfile "${PIDFILE}" --exec /usr/bin/tor -- --PidFile "${PIDFILE}"
    
    rc=$?                     <-------------
    eend "done"               <-------------
    eend $rc                  <-------------
}


:-D
Comment 9 Toralf Förster gentoo-dev 2014-12-20 17:51:35 UTC
(In reply to Toralf Förster from comment #8)
>     
>     rc=$?                     <-------------
better:
    local rc=0
Comment 10 Anthony Basile gentoo-dev 2014-12-23 15:30:50 UTC
(In reply to Toralf Förster from comment #9)
> (In reply to Toralf Förster from comment #8)
> >     
> >     rc=$?                     <-------------
> better:
>     local rc=0

You mean just add local rc=0 at the top of gracefulstop()?
Comment 11 Toralf Förster gentoo-dev 2014-12-23 16:59:27 UTC
(In reply to Anthony Basile from comment #10)
> (In reply to Toralf Förster from comment #9)
> > (In reply to Toralf Förster from comment #8)
> > >     
> > >     rc=$?                     <-------------
> > better:
> >     local rc=0
> 
> You mean just add local rc=0 at the top of gracefulstop()?

yes, so something like this :

gracefulstop() {
        local rc=0
        ebegin "Gracefully stopping Tor"
        ebegin "This can take up to ${GRACEFUL_TIMEOUT} seconds"
        start-stop-daemon -P --stop --signal INT -R ${GRACEFUL_TIMEOUT} --pidfile "${PIDFILE}" --exec /usr/bin/tor -- --PidFile "${PIDFILE}"
        rc=$?
        eend "done"
        eend $rc
}
Comment 12 Anthony Basile gentoo-dev 2014-12-23 17:27:57 UTC
Okay its in as follows without a rev bump so resync and test.  Submit a patch next time so there's no ambiguity.

Index: files/tor.initd-r7
===================================================================
RCS file: /var/cvsroot/gentoo-x86/net-misc/tor/files/tor.initd-r7,v
retrieving revision 1.1
diff -u -B -r1.1 tor.initd-r7
--- files/tor.initd-r7	23 Sep 2014 23:14:00 -0000	1.1
+++ files/tor.initd-r7	23 Dec 2014 17:24:17 -0000
@@ -63,10 +63,13 @@
 }
 
 gracefulstop() {
+	local rc=0
         ebegin "Gracefully stopping Tor"
 	ebegin "This can take up to ${GRACEFUL_TIMEOUT} seconds"
 	start-stop-daemon -P --stop --signal INT -R ${GRACEFUL_TIMEOUT} --pidfile "${PIDFILE}" --exec /usr/bin/tor -- --PidFile "${PIDFILE}"
-	eend $?
+	rc=$?
+	eend "done"
+	eend $rc
 }
 
 reload() {