Feature #619

Check if the child is frozen

Added by Alexandre Quessy over 3 years ago. Updated 11 months ago.

Status:New Start date:
Priority:Normal Due date:
Assignee:Alexandre Quessy % Done:

0%

Category:slave Spent time: -
Target version:0.8
Resolution: Version:
Trac ticket ID:13

Description

If process is a zombie, kill it !

See http://bitbucket.org/chrismiles/psi/src/tip/src/arch/linux_process.c in the Python module psi, maybe ? It reads in /proc to get some informations. I think it's when calling psi.process.Process.exists()

History

Updated by Alexandre Quessy over 3 years ago

/** Decode the state character from /proc/<pid>/stat or /proc/<pid>/status
 *
* Returns an int with the correct PROC_STATUS_* constant in.
 */
static int
decode_state(const char state)
{
    int tmpi;

    switch (state) {
    case 'R':
        tmpi = PROC_STATUS_RUNNING;
        break;
    case 'S':
        tmpi = PROC_STATUS_SLEEPING;
        break;
    case 'D':
        tmpi = PROC_STATUS_DISKSLEEP;
        break;
    case 'Z':
        tmpi = PROC_STATUS_ZOMBIE;
        break;
    case 'T':
        tmpi = PROC_STATUS_STOPPED;
        break;
    case 'W':
        tmpi = PROC_STATUS_PAGING;
        break;
    case 'X':
        tmpi = PROC_STATUS_DEAD;
        break;
    default:
        [[PyErr]]_Format(PyExc_OSError, "Invalid/unknown state: %s", &state);
        return -1;
    }
    return tmpi;
}

Updated by Alexandre Quessy over 3 years ago

We should make sure the child is really running. Of course, we need to do this command on a remote host if it is remote. Actually, we would do the equivalent (reading files if on Linux) of this in the lunch-slave :

do awk '/State/ { print $2 }' /proc/$(pidof xeyes)/status; done

ok if status starts with [S, R]
Not ok is status starts with [Z, T, X]

PROCESS STATE CODES
       Here are the different values that the s, stat and state output specifiers (header "STAT" or "S") will
       display to describe the state of a process.
       D    Uninterruptible sleep (usually IO)
       R    Running or runnable (on run queue)
       S    Interruptible sleep (waiting for an event to complete)
       T    Stopped, either by a job control signal or because it is being traced.
       W    paging (not valid since the 2.6.xx kernel)
       X    dead (should never be seen)
       Z    Defunct ("zombie") process, terminated but not reaped by its parent.

       For BSD formats and when the stat keyword is used, additional characters may be displayed:
       <    high-priority (not nice to other users)
       N    low-priority (nice to other users)
       L    has pages locked into memory (for real-time and custom IO)
       s    is a session leader
       l    is multi-threaded (using CLONE_THREAD, like NPTL pthreads do)
       +    is in the foreground process group

Updated by Alexandre Quessy over 3 years ago

I guess the process is ok if its state is D. (disk sleep)

Updated by Alexandre Quessy over 3 years ago

What is the state of a zombie jackd?

Updated by Alexandre Quessy almost 3 years ago

  • Twisted's process protocol will be warned if it dies.
  • A zombie has no parent. We'll know if the lunch-slave dies.
  • If it stuck, we can send it a signal 0. If it throws and error or get stuck... that might mean the process is stuck. (?)

Updated by Alexandre Quessy 11 months ago

  • Target version changed from 0.6 to 0.8

Also available in: Atom PDF