Nov 032009
 

A zombie, or defunct, process is a process that has terminated, but its parent process has not taken it out of the process table with the wait() family of system calls. This typically happens when a program forks/execs another program, but then doesn’t reap it properly. The easiest way to write the parent to properly reap its children is to setup a signal handler for SIGCHLD that calls wait().

See the man pages on your local system for signal and wait(2).

Zombie and defunct states of a process are different things. Zombie is created when a child dies and parent didn’t call wait. Defunct is created when parent dies before the child finishes.

Defunct processes can’t be killed since they are already dead. To make them disappear you have to kill their parent process…

It’s not possible to kill defunct processes.

A good way to kill lists of processes is:

$ ps axf | grep name-of-process | grep -v -grep | awk '{print "kill -9 ",$1}' | sh

Continue reading »

Oct 082009
 

Suppose we have umask 0002 for our user default permission.

    $ umask
    0002

Create new directory

    $ mkdir tmpdir

tmpdir directory created with its default permission 775

    $ ls -l
    ..........
    ..........
    drwxrwxr-x  2 harry harry      4096 Oct  8 06:59 tmp
    ..........
    ..........

Create new file

    $ touch tmpfile

tmpfile file created with its default permission 664

    $ ls -l
    -rw-rw-r--  1 harry harry 0 Oct  8 07:06 tmpfile

Now, let’s see how the file permission settings are calculated using boolean expressions with default umask 0002.

For e.g. consider the case where we have default umask value of 0002 – 0000 0000 0000 0010
1’s complement of 0002 – 1111 1111 1111 1101

For directories perform logical AND operation with 0777 (0000 0111 0111 0111). So

    1111 1111 1111 1101 (1’s complement of 0002)
    0000 0111 0111 0111 (0777, base permission of directory)
    —————-------------- AND
    0000 0111 0111 0101 = 0775

For files, perfom logical AND operation with 0666 (0000 0110 0110 0110), so

    1111 1111 1111 1101 (1’s complement of 0002)
    0000 0110 0110 0110 (0666, base permission of file)
    —————-------------- AND
    0000 0110 0110 0100 = 0664

we can try different combination of umask value, so we can get a clear picture on how umask is applied to determine default permission on newly created files or directories.