Page 1 of 1

Unrar Zombie Process - Fedora 19 - v0.7.16

Posted: February 12th, 2014, 12:29 am
by diedjee
Immediately after launching sabnzbd 0.7.16, a zombie unrar process appears in my process list.

No downloads were scheduled in my queue. Sabnzbd is idling.

I'm running Fedora 19, kernel 3.12.9.

process list:

Code: Select all

# ps aux | grep sabnzbd | grep -v grep
root      7087  0.0  0.0 206872  3420 pts/4    S+   06:20   0:00 sudo -u sabnzbd SABnzbd
sabnzbd   7088  0.4  0.1 1882724 50280 pts/4   Sl+  06:20   0:01 /usr/bin/python -OO /usr/share/SABnzbd/SABnzbd.py
sabnzbd   7092  0.0  0.0      0     0 pts/4    Z+   06:20   0:00 [unrar] <defunct>
log output:

Code: Select all

$ sudo -u sabnzbd SABnzbd 
No protocol specified
2014-02-12 06:20:19,485::INFO::[SABnzbd:1256] --------------------------------
2014-02-12 06:20:20,392::INFO::[SABnzbd:1257] SABnzbd.py-0.7.16 (rev=14f39a21e3aa063d128f16505032e759c7ba3265)
2014-02-12 06:20:20,392::INFO::[SABnzbd:1269] Platform = posix
2014-02-12 06:20:20,392::INFO::[SABnzbd:1270] Python-version = 2.7.5 (default, Nov 12 2013, 16:18:42) 
[GCC 4.8.2 20131017 (Red Hat 4.8.2-1)]
2014-02-12 06:20:20,393::INFO::[SABnzbd:1271] Arguments = /usr/share/SABnzbd/SABnzbd.py
2014-02-12 06:20:20,393::INFO::[SABnzbd:1284] Read INI file /home/sabnzbd/.sabnzbd/sabnzbd.ini
2014-02-12 06:20:20,394::INFO::[__init__:928] Loading data for bookmarks.sab from /home/sabnzbd/.sabnzbd/admin/bookmarks.sab
2014-02-12 06:20:20,394::INFO::[__init__:928] Loading data for rss_data.sab from /home/sabnzbd/.sabnzbd/admin/rss_data.sab
2014-02-12 06:20:20,394::INFO::[__init__:928] Loading data for totals9.sab from /home/sabnzbd/.sabnzbd/admin/totals9.sab
2014-02-12 06:20:20,394::INFO::[postproc:90] Loading postproc queue
2014-02-12 06:20:20,394::INFO::[__init__:928] Loading data for postproc1.sab from /home/sabnzbd/.sabnzbd/admin/postproc1.sab
2014-02-12 06:20:20,395::INFO::[__init__:928] Loading data for queue9.sab from /home/sabnzbd/.sabnzbd/admin/queue9.sab
2014-02-12 06:20:20,395::INFO::[__init__:928] Loading data for watched_data.sab from /home/sabnzbd/.sabnzbd/admin/watched_data.sab
2014-02-12 06:20:20,395::INFO::[scheduler:172] Setting schedule for midnight BPS reset
2014-02-12 06:20:20,396::INFO::[downloader:211] Resuming
2014-02-12 06:20:20,396::INFO::[__init__:330] All processes started
2014-02-12 06:20:20,396::INFO::[SABnzbd:334] Web dir is /usr/share/SABnzbd/interfaces/Plush
2014-02-12 06:20:20,396::INFO::[SABnzbd:334] Web dir is /usr/share/SABnzbd/interfaces/Config
2014-02-12 06:20:20,399::INFO::[SABnzbd:463] _yenc module... found!
2014-02-12 06:20:20,399::INFO::[SABnzbd:471] par2 binary... found (/bin/par2)
2014-02-12 06:20:20,399::INFO::[SABnzbd:479] unrar binary... found (/bin/unrar)
2014-02-12 06:20:20,399::INFO::[SABnzbd:484] unzip binary... found (/bin/unzip)
2014-02-12 06:20:20,399::INFO::[SABnzbd:490] nice binary... found (/bin/nice)
2014-02-12 06:20:20,399::INFO::[SABnzbd:494] ionice binary... found (/bin/ionice)
2014-02-12 06:20:20,399::INFO::[SABnzbd:499] pyOpenSSL... found (True)
2014-02-12 06:20:20,400::INFO::[SABnzbd:1483] Starting web-interface on 127.0.0.1:8080
2014-02-12 06:20:20,401::INFO::[_cplogging:55] [12/Feb/2014:06:20:20] ENGINE Bus STARTING
2014-02-12 06:20:20,402::INFO::[_cplogging:55] [12/Feb/2014:06:20:20] ENGINE Started monitor thread '_TimeoutMonitor'.
2014-02-12 06:20:20,603::INFO::[_cplogging:55] [12/Feb/2014:06:20:20] ENGINE Serving on 127.0.0.1:8080
2014-02-12 06:20:20,604::INFO::[_cplogging:55] [12/Feb/2014:06:20:20] ENGINE Bus STARTED
2014-02-12 06:20:26,428::INFO::[SABnzbd:1552] Starting SABnzbd.py-0.7.16
2014-02-12 06:20:26,429::INFO::[dirscanner:274] Dirscanner starting up
2014-02-12 06:20:26,430::INFO::[urlgrabber:77] URLGrabber starting up

Re: Unrar Zombie Process - Fedora 19 - v0.7.16

Posted: February 12th, 2014, 4:52 am
by shypike
At startup the unrar program is run to check its version number.
Possibly your Fedora installation has an incompatible version that shows some odd behavior.

Can you check which unrar program you have?
Just run it from a terminal session and check its signon.
We only support the freeware, but commercial version of unrar.
You can obtain it here: http://www.rarlab.com/rar_add.htm
Fedora RPM-s are available.

Re: Unrar Zombie Process - Fedora 19 - v0.7.16

Posted: February 12th, 2014, 7:36 am
by diedjee
Already using the one from rpmfusion:

Code: Select all

$ yum info unrar
Installed Packages
Name        : unrar
Arch        : x86_64
Version     : 4.2.4
Release     : 4.fc19
Size        : 217 k
Repo        : installed
From repo   : rpmfusion-nonfree-updates
Summary     : Utility for extracting, testing and viewing RAR archives
URL         : http://www.rarlab.com/rar_add.htm
License     : Freeware with further limitations
Description : The unrar utility is a freeware program for extracting, testing
            : and viewing the contents of archives created with the RAR archiver
            : version 1.50 and above.
Help of unrar:

Code: Select all

$ unrar

UNRAR 4.20 freeware      Copyright (c) 1993-2012 Alexander Roshal

Usage:     unrar <command> -<switch 1> -<switch N> <archive> <files...>
               <@listfiles...> <path_to_extract\>

<Commands>
  e             Extract files to current directory
  l[t,b]        List archive [technical, bare]
  p             Print file to stdout
  t             Test archive files
  v[t,b]        Verbosely list archive [technical,bare]
  x             Extract files with full path

<Switches>
  -             Stop switches scanning
  @[+]          Disable [enable] file lists
  ad            Append archive name to destination path
  ag[format]    Generate archive name using the current date
  ai            Ignore file attributes
  ap<path>      Set path inside archive
  c-            Disable comments show
  cfg-          Disable read configuration
  cl            Convert names to lower case
  cu            Convert names to upper case
  dh            Open shared files
  ep            Exclude paths from names
  ep3           Expand paths to full including the drive letter
  f             Freshen files
  id[c,d,p,q]   Disable messages
  ierr          Send all messages to stderr
  inul          Disable all messages
  kb            Keep broken extracted files
  n<file>       Include only specified file
  n@            Read file names to include from stdin
  n@<list>      Include files listed in specified list file
  o[+|-]        Set the overwrite mode
  or            Rename files automatically
  ow            Save or restore file owner and group
  p[password]   Set password
  p-            Do not query password
  r             Recurse subdirectories
  sl<size>      Process files with size less than specified
  sm<size>      Process files with size more than specified
  ta<date>      Process files modified after <date> in YYYYMMDDHHMMSS format
  tb<date>      Process files modified before <date> in YYYYMMDDHHMMSS format
  tn<time>      Process files newer than <time>
  to<time>      Process files older than <time>
  ts<m,c,a>[N]  Save or restore file time (modification, creation, access)
  u             Update files
  v             List all volumes
  ver[n]        File version control
  vp            Pause before each volume
  x<file>       Exclude specified file
  x@            Read file names to exclude from stdin
  x@<list>      Exclude files listed in specified list file
  y             Assume Yes on all queries
Enabling debug does not produce anything interesting.

Code: Select all

$ sudo -u sabnzbd SABnzbd
No protocol specified
2014-02-12 13:29:46,944::INFO::[SABnzbd:1256] --------------------------------
2014-02-12 13:29:46,944::INFO::[SABnzbd:1257] SABnzbd.py-0.7.16 (rev=14f39a21e3aa063d128f16505032e759c7ba3265)
2014-02-12 13:29:46,944::INFO::[SABnzbd:1269] Platform = posix
2014-02-12 13:29:46,944::INFO::[SABnzbd:1270] Python-version = 2.7.5 (default, Nov 12 2013, 16:18:42) 
[GCC 4.8.2 20131017 (Red Hat 4.8.2-1)]
2014-02-12 13:29:46,944::INFO::[SABnzbd:1271] Arguments = /usr/share/SABnzbd/SABnzbd.py
2014-02-12 13:29:46,944::INFO::[SABnzbd:1284] Read INI file /home/sabnzbd/.sabnzbd/sabnzbd.ini
2014-02-12 13:29:46,945::INFO::[__init__:928] Loading data for bookmarks.sab from /home/sabnzbd/.sabnzbd/admin/bookmarks.sab
2014-02-12 13:29:46,945::INFO::[__init__:928] Loading data for rss_data.sab from /home/sabnzbd/.sabnzbd/admin/rss_data.sab
2014-02-12 13:29:46,945::INFO::[__init__:928] Loading data for totals9.sab from /home/sabnzbd/.sabnzbd/admin/totals9.sab
2014-02-12 13:29:46,946::DEBUG::[bpsmeter:171] Read quota q=0.0 l=0.0 reset=0
2014-02-12 13:29:46,946::INFO::[postproc:90] Loading postproc queue
2014-02-12 13:29:46,946::INFO::[__init__:928] Loading data for postproc1.sab from /home/sabnzbd/.sabnzbd/admin/postproc1.sab
2014-02-12 13:29:46,946::INFO::[__init__:928] Loading data for queue9.sab from /home/sabnzbd/.sabnzbd/admin/queue9.sab
2014-02-12 13:29:46,946::DEBUG::[downloader:127] Initializing downloader/decoder
2014-02-12 13:29:46,947::INFO::[__init__:928] Loading data for watched_data.sab from /home/sabnzbd/.sabnzbd/admin/watched_data.sab
2014-02-12 13:29:46,947::DEBUG::[scheduler:140] Scheduling RSS interval task every 60 min (delay=8)
2014-02-12 13:29:46,947::DEBUG::[scheduler:152] Scheduling VersionCheck on day 3 at 10:37
2014-02-12 13:29:46,947::INFO::[scheduler:172] Setting schedule for midnight BPS reset
2014-02-12 13:29:46,947::INFO::[downloader:211] Resuming
2014-02-12 13:29:46,947::DEBUG::[__init__:532] PAUSED_ALL inactive
2014-02-12 13:29:46,948::INFO::[__init__:330] All processes started
2014-02-12 13:29:46,948::INFO::[SABnzbd:334] Web dir is /usr/share/SABnzbd/interfaces/Plush
2014-02-12 13:29:46,948::INFO::[SABnzbd:334] Web dir is /usr/share/SABnzbd/interfaces/Config
2014-02-12 13:29:46,951::INFO::[SABnzbd:463] _yenc module... found!
2014-02-12 13:29:46,951::INFO::[SABnzbd:471] par2 binary... found (/bin/par2)
2014-02-12 13:29:46,951::INFO::[SABnzbd:479] unrar binary... found (/bin/unrar)
2014-02-12 13:29:46,951::INFO::[SABnzbd:484] unzip binary... found (/bin/unzip)
2014-02-12 13:29:46,951::INFO::[SABnzbd:490] nice binary... found (/bin/nice)
2014-02-12 13:29:46,951::INFO::[SABnzbd:494] ionice binary... found (/bin/ionice)
2014-02-12 13:29:46,951::INFO::[SABnzbd:499] pyOpenSSL... found (True)
2014-02-12 13:29:46,952::INFO::[SABnzbd:1483] Starting web-interface on 127.0.0.1:8080
2014-02-12 13:29:46,952::INFO::[_cplogging:55] [12/Feb/2014:13:29:46] ENGINE Bus STARTING
2014-02-12 13:29:46,954::INFO::[_cplogging:55] [12/Feb/2014:13:29:46] ENGINE Started monitor thread '_TimeoutMonitor'.
2014-02-12 13:29:47,055::INFO::[_cplogging:55] [12/Feb/2014:13:29:47] ENGINE Serving on 127.0.0.1:8080
2014-02-12 13:29:47,055::INFO::[_cplogging:55] [12/Feb/2014:13:29:47] ENGINE Bus STARTED
2014-02-12 13:29:47,056::DEBUG::[notifier:112] Sending registration to localhost:23053
2014-02-12 13:29:47,056::DEBUG::[notifier:102] Checking icon
2014-02-12 13:29:47,057::DEBUG::[notifier:219] To : localhost:23053 <<class 'gntp.GNTPRegister'>>
2014-02-12 13:29:47,057::DEBUG::[growler:171] Cannot register with Growl [Errno 111] Connection refused
2014-02-12 13:30:08,011::DEBUG::[misc:598] Checked for a new release, cur= 71699, latest= 71699 (on http://sourceforge.net/projects/sabnzbdplus/files/sabnzbdplus/0.7.16/)
2014-02-12 13:30:08,012::INFO::[SABnzbd:1552] Starting SABnzbd.py-0.7.16
2014-02-12 13:30:08,012::DEBUG::[__init__:341] Starting postprocessor
2014-02-12 13:30:08,012::DEBUG::[__init__:344] Starting assembler
2014-02-12 13:30:08,012::DEBUG::[__init__:347] Starting downloader
2014-02-12 13:30:08,013::DEBUG::[scheduler:188] Starting scheduler
2014-02-12 13:30:08,013::DEBUG::[__init__:352] Starting dirscanner
2014-02-12 13:30:08,013::INFO::[dirscanner:274] Dirscanner starting up
2014-02-12 13:30:08,013::DEBUG::[__init__:357] Starting urlgrabber
2014-02-12 13:30:08,014::INFO::[urlgrabber:77] URLGrabber starting up
^C2014-02-12 13:33:46,683::WARNING::[__init__:169] Signal 2 caught, saving and exiting...
2014-02-12 13:33:46,684::INFO::[nzbqueue:211] Saving queue
2014-02-12 13:33:46,684::INFO::[__init__:904] Saving data for queue9.sab in /home/sabnzbd/.sabnzbd/admin/queue9.sab
2014-02-12 13:33:46,684::INFO::[__init__:904] Saving data for totals9.sab in /home/sabnzbd/.sabnzbd/admin/totals9.sab
2014-02-12 13:33:46,685::INFO::[__init__:904] Saving data for rss_data.sab in /home/sabnzbd/.sabnzbd/admin/rss_data.sab
2014-02-12 13:33:46,685::INFO::[__init__:904] Saving data for bookmarks.sab in /home/sabnzbd/.sabnzbd/admin/bookmarks.sab
2014-02-12 13:33:46,685::INFO::[__init__:904] Saving data for watched_data.sab in /home/sabnzbd/.sabnzbd/admin/watched_data.sab
2014-02-12 13:33:46,685::INFO::[postproc:84] Saving postproc queue
2014-02-12 13:33:46,685::INFO::[__init__:904] Saving data for postproc1.sab in /home/sabnzbd/.sabnzbd/admin/postproc1.sab
What do you mean by signon?

Re: Unrar Zombie Process - Fedora 19 - v0.7.16

Posted: February 12th, 2014, 8:03 am
by sander
unrar looks good.

Let's simulate SABnzbd's version check to see if you get a zombie process:

create a file rar-test.py with this content

Code: Select all

import subprocess
import re
import sys

def unrar_check(rar):
    """ Return True if correct version of unrar is found """
    if rar:
        try:
            version = subprocess.Popen(rar, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True).stdout.read()
        except:
            return False
        m = re.search(r"RAR\s(\d+)\.(\d+)\s+.*Alexander Roshal", version)
        if m:
            print m.group(1), m.group(2)
            return (int(m.group(1)), int(m.group(2))) >= (3, 80)
    return False

try:
    unrar = sys.argv[1]
except:
    sys.exit("not good")

print unrar_check(unrar)
and then run it it like:

Code: Select all

python rar-test.py  `which unrar`
Output should be like:

Code: Select all

$ python rar-test.py  `which unrar`
4 00
True

If so ... is there a zombie process running afterwards?

Post back the result.

Re: Unrar Zombie Process - Fedora 19 - v0.7.16

Posted: February 12th, 2014, 8:38 am
by diedjee
Output is

Code: Select all

# sudo -u sabnzbd python rar-test.py `which unrar`
4 20
True
No zombie process is running afterwards. This is normal behavior: the calling process has finished execution.
(Check the wikipedia entry for the definition of zombie process)

When I modify your python script as follows, the zombie process remains until I send an EOF.
Again, normal behavior, as the calling process is still active.

Code: Select all

import subprocess
import re
import sys

def unrar_check(rar):
    """ Return True if correct version of unrar is found """
    if rar:
        try:
            version = subprocess.Popen(rar, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True).stdout.read()
        except:
            return False
        m = re.search(r"RAR\s(\d+)\.(\d+)\s+.*Alexander Roshal", version)
        if m:
            print m.group(1), m.group(2)
            return (int(m.group(1)), int(m.group(2))) >= (3, 80)
    return False

try:
    unrar = sys.argv[1]
except:
    sys.exit("not good")

print unrar_check(unrar)
sys.stdin.read()
While running python-test.rar:

Code: Select all

$ sudo ps aux | grep sabnzbd | grep -v grep
root      4274  0.0  0.0 206868  3396 pts/0    S+   14:36   0:00 sudo -u sabnzbd python rar-test.py /bin/unrar
sabnzbd   4275  0.0  0.0 136056  4704 pts/0    S+   14:36   0:00 python rar-test.py /bin/unrar
sabnzbd   4276  0.0  0.0      0     0 pts/0    Z+   14:36   0:00 [unrar] <defunct>
No entries in the process table after sending it EOF.

Re: Unrar Zombie Process - Fedora 19 - v0.7.16

Posted: February 12th, 2014, 9:07 am
by diedjee
Adding a wait fixes rar-test.py:

Code: Select all

import subprocess
import re
import sys

def unrar_check(rar):
    """ Return True if correct version of unrar is found """
    if rar:
        try:
            p = subprocess.Popen(rar, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
            version = p.stdout.read()
        except:
            return False
        m = re.search(r"RAR\s(\d+)\.(\d+)\s+.*Alexander Roshal", version)
        if m:
            print m.group(1), m.group(2)
            p.wait()
            return (int(m.group(1)), int(m.group(2))) >= (3, 80)
    return False

try:
    unrar = sys.argv[1]
except:
    sys.exit("not good")

print unrar_check(unrar)
sys.stdin.read()

Code: Select all

$ sudo ps aux | grep sabnzbd | grep -v grep
root      4778  0.0  0.0 206868  3400 pts/0    S+   15:03   0:00 sudo -u sabnzbd python rar-test.py /bin/unrar
sabnzbd   4779  0.1  0.0 136056  4708 pts/0    S+   15:03   0:00 python rar-test.py /bin/unrar
I just did a (admittedly low-level) strace of SABnzbd and I found a (the) problem/symptom.

Code: Select all

$ sudo -u sabnzbd strace -o output -ff SABnzbd
The SABnzbd process has PID 4370, the zombie process has PID 4375:

Code: Select all

$ sudo ps aux | grep sabnzbd | grep -v grep
root      4364  0.0  0.0 206872  3416 pts/1    S+   14:41   0:00 sudo -u sabnzbd strace -o output -ff SABnzbd
sabnzbd   4365  3.3  0.0   4764   936 pts/1    S+   14:41   0:00 strace -o output -ff SABnzbd
sabnzbd   4370  5.5  0.1 1366460 42552 pts/1   Sl+  14:41   0:00 /usr/bin/python -OO /usr/share/SABnzbd/SABnzbd.py
sabnzbd   4375  0.0  0.0      0     0 pts/1    Z+   14:41   0:00 [unrar] <defunct>
Examining the trace file of pid 4370 contains the following lines of interest concerning pid 4375:

Code: Select all

(snip)
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f186ce71a10) = 4375
(snip)
wait4(4375, 0x7fff78fe230c, WNOHANG, NULL) = 0
fstat(3, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
lseek(3, 0, SEEK_CUR)                   = -1 ESPIPE (Illegal seek)
read(3, "\nUNRAR", 6)                   = 6
fstat(3, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
lseek(3, 0, SEEK_CUR)                   = -1 ESPIPE (Illegal seek)
read(3, " 4.20 ", 6)                    = 6
fstat(3, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
lseek(3, 0, SEEK_CUR)                   = -1 ESPIPE (Illegal seek)
read(3, "freewar", 7)                   = 7
fstat(3, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
lseek(3, 0, SEEK_CUR)                   = -1 ESPIPE (Illegal seek)
read(3, "e      C", 8)                  = 8
(snip)
Reading the manual of wait shows the following definition:

Code: Select all

RETURN VALUE
(snip)
       waitpid(): on success, returns the process ID of the child whose state has changed; if  WNOHANG
       was  specified  and  one  or  more  child(ren) specified by pid exist, but have not yet changed
       state, then 0 is returned.  On error, -1 is returned.
The caller (=sabnzbd) thus never waits for the unrar process to finish execution.
This is a race condition, the wait occurs too early. Does the wait really needs the WNOHANG argument?
The WNOHANG in this wait4 is the only WNOHANG appearing in the trace output.

Re: Unrar Zombie Process - Fedora 19 - v0.7.16

Posted: February 12th, 2014, 9:11 am
by sander
Interesting!

Do you think you can tweak

Code: Select all

version = subprocess.Popen(rar, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True).stdout.read()
so that it does not result in a zombie process ?

Re: Unrar Zombie Process - Fedora 19 - v0.7.16

Posted: February 12th, 2014, 9:55 am
by diedjee
Yes, replace the subprocess line with the three-liner:

Code: Select all

p = subprocess.Popen(rar, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
version = p.stdout.read()
p.wait()
This will block if the process refuses to close.
That behavior is already present: most probably the read on stdout would also block.

Why the need for shell=True?
Why does logging.debug not work inside unrar_check?

I changed the corresponding lines in sabnzbd/newsunpack.py. The zombie process is now gone.

Re: Unrar Zombie Process - Fedora 19 - v0.7.16

Posted: February 12th, 2014, 11:22 am
by shypike
I'll try to get this fix into the next release.
Thank you both for researching it.

Re: Unrar Zombie Process - Fedora 19 - v0.7.16

Posted: February 13th, 2014, 4:55 am
by sander
FWIW: On my Ubuntu 12.04.4 LTS I cannot reproduce the hanging/zombie unrar with SABnzbd nor with diedjee's script (the script that waits for input and so does not exit):

Code: Select all

$ ps aux | grep -e rar -e Z -e nzbd
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
sander   19560  0.2  3.5 202992 18228 ?        Sl   10:41   0:01 /usr/bin/python -OO /usr/bin/sabnzbdplus --daemon --pidfile /var/run/sabnzbdplus/pid 
sander   19637  0.0  0.8  10904  4356 pts/0    S+   10:44   0:00 python rar-test2.py /usr/bin/unrar
sander   19638  0.0  0.0      0     0 pts/0    Z+   10:44   0:00 [sh] <defunct>
sander   19951  0.0  0.1   4388   828 pts/1    S+   10:53   0:00 grep --color=auto -e rar -e Z -e nzbd
sander@haring:~$

Am I doing something wrong, or is this a Fedora specific thing?

Re: Unrar Zombie Process - Fedora 19 - v0.7.16

Posted: February 13th, 2014, 5:53 am
by shypike
diedjee says it's a race condition.
That means that it may happen, but doesn't have to.

Re: Unrar Zombie Process - Fedora 19 - v0.7.16

Posted: February 13th, 2014, 7:57 am
by diedjee
Yep, totally a race condition.

Check this snippet without a wait. No zombie process while waiting for stdin:

Code: Select all

import subprocess
import re
import sys

def unrar_check(rar):
    """ Return True if correct version of unrar is found """
    if rar:
        try:
            p = subprocess.Popen(rar, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
            import time
            time.sleep(10)
            version = p.stdout.read()
        except:
            return False
        m = re.search(r"RAR\s(\d+)\.(\d+)\s+.*Alexander Roshal", version)
        if m:
            print m.group(1), m.group(2)
            return (int(m.group(1)), int(m.group(2))) >= (3, 80)
    return False

try:
    unrar = sys.argv[1]
except:
    sys.exit("not good")

print unrar_check(unrar)
sys.stdin.read(
To make things even crazier: changing the one-liner

Code: Select all

version = subprocess.Popen(rar, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True).stdout.read()
to the two-liner

Code: Select all

p = subprocess.Popen(rar, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
version = p.stdout.read()
also gets rid of the zombie.

Anyhow, my advice remains to replace it with the three-liner.