Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 294435 - net-p2p/rtorrent refuses to start in daemon mode if /usr/bin/screen is already running
Summary: net-p2p/rtorrent refuses to start in daemon mode if /usr/bin/screen is alread...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Server (show other bugs)
Hardware: AMD64 Linux
: High normal with 1 vote (vote)
Assignee: No maintainer - Look at https://wiki.gentoo.org/wiki/Project:Proxy_Maintainers if you want to take care of it
URL:
Whiteboard:
Keywords:
: 300309 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-11-24 16:26 UTC by Kolbjørn Fredheim
Modified: 2011-05-09 14:19 UTC (History)
7 users (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 Kolbjørn Fredheim 2009-11-24 16:26:48 UTC
/etc/init.d/rtorrentd refuses to start if anyone is running a session of screen on the system. Simple fix is to add --user $USER to the init script.


Reproducible: Always

Steps to Reproduce:
1. Fire up a screen session
2. Detatch that screen session or open up another terminal
3. /etc/init.d/rtorrentd start

Actual Results:  
# /etc/init.d/rtorrentd restart
 * Caching service Dependencies ...                                     [ ok ]
 * Starting rtorrent ...
/usr/bin/screen already running.                                        [ !! ]

Expected Results:  
# /etc/init.d/rtorrentd restart
 * Caching service Dependencies ...                                     [ ok ]
 * Starting rtorrent ...                                                [ ok ]

Adding --user $USER to the /etc/init.d/rtorrentd script takes care of the issue for me.

ebegin "Starting rtorrent"
env TERM="xterm" \
start-stop-daemon --start --chuid $USER --user $USER \
--env HOME="${PWHOME:-/home/$USER}" \
--exec /usr/bin/screen -- -dmS rtorrentd /usr/bin/rtorrent
eend $?
Comment 1 Scott 2009-12-06 20:14:42 UTC
(In reply to comment #0)
> /etc/init.d/rtorrentd refuses to start if anyone is running a session of screen
> on the system. Simple fix is to add --user $USER to the init script.
> 
> 

Adding --user $USER does not solve the problem if the given user already has screen running; this forces rtorrent to have its own user specifically for this purpose. 

Another option would be to create a new executable (e.g. /usr/bin/rtorrentd):

#!/bin/bash
/usr/bin/screen -dmS rtorrentd /usr/bin/rtorrent

would do the trick, and then run that.
Comment 2 Ewoud Kohl van Wijngaarden 2010-01-04 01:14:39 UTC
I had the same issue (even though ps aux didn't show any screens). Adding --name rtorrent seems to have solved it.
Comment 3 Samuli Suominen (RETIRED) gentoo-dev 2010-01-22 15:44:39 UTC
*** Bug 300309 has been marked as a duplicate of this bug. ***
Comment 4 Dror Levin (RETIRED) gentoo-dev 2010-03-18 20:30:34 UTC
I have committed a supposed fix, please test (don't forget to re-emerge) and verify it works.
Comment 5 Irr0 R Irregular 2010-04-18 09:10:47 UTC
For some strange reasons my rtorrent with new init.d script is running as root. I think we need --chuid option for start-stop-daemon too, because --user only "check for processes owned by the user specified by username or uid".
And no, new init.d script doesn't fix main bug, because rtorrent runned as root, but start-stop-daemon expects $USER process.
Comment 6 Kolan Sh. 2010-07-05 14:54:23 UTC
Hi all! I've installed rtorrent today and faced with this problem too on rtorrent-0.8.6-r1.
Perhaps on a new version of rtorrent all is ok, but I'll print full working config here to be on the safe side.

#!/sbin/runscript
# Copyright 1999-2008 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-p2p/rtorrent/files/rtorrentd.init,v 1.5 2010/03/18 20:30:24 spatz Exp $

depend() {
        use net ypbind nis
        after slapd mysqld postgresql
}

start() {
        PWHOME="$(getent passwd $USER | awk -F: '{ print $6 }')"

        ebegin "Starting rtorrent"
        env TERM="xterm" \
                start-stop-daemon \
                        --start \
                        --chuid $USER \
                        --user $USER \
                        --chdir /home/$USER \
                        --env HOME="${PWHOME:-/home/$USER}" \
                        --name rtorrent \
                        --exec /usr/bin/screen -- -d -m -S rtorrentd /usr/bin/rtorrent
        eend $?
}

stop() {
        ebegin "Stopping rtorrent"
        start-stop-daemon --stop --signal 2 --name rtorrent
        eend $?
}
# With best regards
# Kolan
Comment 7 Robert Spencer 2010-10-08 13:41:42 UTC
I just wanted to note that the init.d script still does not run as the user listed in /etc/conf.d/rtorrentd unless --chuid $USER \
is added to the script as noted in comment #6.
Comment 8 Kolan Sh. 2010-10-08 14:04:39 UTC
And I still would like to pay attention for the line (works)
--exec /usr/bin/screen -- -d -m -S rtorrentd
as the original
--exec /usr/bin/screen -- -dmS rtorrentd /usr/bin/rtorrent
in my system doesn't lead to daemon start.
Comment 9 Kolan Sh. 2010-10-08 14:06:46 UTC
> --exec /usr/bin/screen -- -d -m -S rtorrentd
My typing error, working variant:
--exec /usr/bin/screen -- -d -m -S rtorrentd /usr/bin/rtorrent

Comment 10 jeremy 2010-11-04 19:35:50 UTC
Ive tried every thing listed here and its still not working for me. say "/usr/bin/screen died"

Details here http://bugs.gentoo.org/show_bug.cgi?id=342517
Comment 11 Stanislav Ochotnicky (RETIRED) gentoo-dev 2011-04-11 21:28:10 UTC
I believe this should be fixed in latest versions (rtorrent-0.8.6-r3, rtorrent-0.8.7-r1). If this still does not fix your problem, feel free to reopen.
Comment 12 Kolan Sh. 2011-05-09 14:19:50 UTC
(In reply to comment #10)
> Ive tried every thing listed here and its still not working for me. say
> "/usr/bin/screen died"
> 
> Details here http://bugs.gentoo.org/show_bug.cgi?id=342517

Jeremi, it seems you are using baselayout-2 and openrc. After the recent update and writing my own crutch run programs from a screen, I've noticed that the start-stop-daemon gives the same error as you said.
Revising a bunch of start-stop-daemon and a screen options, I realized that problem in rc, because screen with -d option calls fork() and rc receives pid of process which finished.

Here is my crutch for rtorrentd which just works:

#!/sbin/runscript

USER=rtorrent

depend() {
        use net ypbind nis
        after slapd mysqld postgresql
}

start() {
        PWHOME="$(getent passwd $USER | awk -F: '{ print $6 }')"

        ebegin "Starting rtorrent"
        cd /home/$USER
        su $USER -c "screen -d -m -S rtorrent /usr/bin/rtorrent"
        eend $?
}

stop() {
        ebegin "Stopping rtorrent"
        start-stop-daemon --stop --signal 2 --name rtorrent
}