# Is there a list of process states somewhere?



## Yujiri (Oct 17, 2020)

By "process states" I mean the states shown in the default SIGINFO output, like 'ttyin', 'runnable', 'uwrlck', `nanslp`.


----------



## PacketMan (Oct 17, 2020)

You mean live on your system, or a general list on a web page somewhere?

https://forums.freebsd.org/threads/what-do-all-the-states-in-top-mean.4910/

Read this:
kqueue(2)


----------



## Yujiri (Oct 17, 2020)

Either one, but I was asking for a list of the possible states. Which according to the thread, there isn't one. Shame, but thanks for answering my question


----------



## Emrion (Oct 18, 2020)

If you speak about the "STATE" that `top` ouputs, actually it's forged from different sources:

/usr/src/usr.bin/top/machine.c

```
/* generate "STATE" field */
    switch (state = pp->ki_stat) {
    case SRUN:
        if (smpmode && pp->ki_oncpu != NOCPU)
            sprintf(status, "CPU%d", pp->ki_oncpu);
        else
            strcpy(status, "RUN");
        break;
    case SLOCK:
        if (pp->ki_kiflag & KI_LOCKBLOCK) {
            sprintf(status, "*%.6s", pp->ki_lockname);
            break;
        }
        /* fall through */
    case SSLEEP:
        sprintf(status, "%.6s", pp->ki_wmesg);
        break;
    default:
        if (state < nitems(state_abbrev)) {
            sprintf(status, "%.6s", state_abbrev[state]);
        } else {
            sprintf(status, "?%5zu", state);
        }
        break;
    }
```
`pp` is a `struct kinfo_proc*`, you can find its definition in /usr/src/sys/sys/user.h.
You can find additional informations in /usr/sys/sys/proc.h

For instance, the state "uwait" comes from sys/kern/kern_umtx.c. You will probably find numerous files that contain a state or another. That said, it would be a good thing to have an explanation of these states in top(1), even if it can't be exhaustive.


----------

