Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Processus et démons sous Unix/Linux

Processus et démons sous Unix/Linux

Jérémy Lecour

April 04, 2014
Tweet

More Decks by Jérémy Lecour

Other Decks in Technology

Transcript

  1. Des processus et démons
    sous Unix/Linux
    Jérémy Lecour — PastisRb et PLUG — avril 2014

    View full-size slide

  2. Jesse Storimer
    jstorimer.com

    View full-size slide

  3. Kernel et appels systèmes

    View full-size slide

  4. Kernel
    Matériel
    Logiciel

    View full-size slide

  5. processus
    Les processus

    View full-size slide

  6. ont un id
    Les processus
    processus

    View full-size slide

  7. ont un parent
    Les processus
    processus

    View full-size slide

  8. ont des ressources ouvertes
    Les processus
    processus

    View full-size slide

  9. ont des limites de ressources
    Les processus
    processus

    View full-size slide

  10. ont un environnement
    Les processus
    processus

    View full-size slide

  11. ont des arguments
    Les processus
    processus

    View full-size slide

  12. ont un nom
    Les processus
    processus

    View full-size slide

  13. ont des codes de retour
    Les processus
    processus

    View full-size slide

  14. peuvent fourcher
    Les processus
    processus

    View full-size slide

  15. peuvent virer Zombie
    Les processus
    processus

    View full-size slide

  16. recevoir des signaux
    Les processus
    processus

    View full-size slide

  17. processus
    Signal Value Action Comment
    -------------------------------------------------------------------------
    SIGHUP 1 Term Hangup detected on controlling terminal
    or death of controlling process
    SIGINT 2 Term Interrupt from keyboard
    SIGQUIT 3 Core Quit from keyboard
    SIGILL 4 Core Illegal Instruction
    SIGABRT 6 Core Abort signal from abort(3)
    SIGFPE 8 Core Floating point exception
    SIGKILL 9 Term Kill signal
    SIGSEGV 11 Core Invalid memory reference
    SIGPIPE 13 Term Broken pipe: write to pipe with no readers
    SIGALRM 14 Term Timer signal from alarm(2)
    SIGTERM 15 Term Termination signal
    SIGUSR1 30,10,16 Term User-defined signal 1
    SIGUSR2 31,12,17 Term User-defined signal 2
    SIGCHLD 20,17,18 Ign Child stopped or terminated
    SIGCONT 19,18,25 Cont Continue if stopped
    SIGSTOP 17,19,23 Stop Stop process
    SIGTSTP 18,20,24 Stop Stop typed at tty
    SIGTTIN 21,21,26 Stop tty input for background process
    SIGTTOU 22,22,27 Stop tty output for background process

    View full-size slide

  18. peuvent communiquer
    Les processus
    processus

    View full-size slide

  19. Qu’est-ce qu’un démon

    View full-size slide

  20. 1. exit if fork
    2. Process.setsid
    3. exit if fork
    4. Dir.chdir "/"
    5. STDIN.reopen "/dev/null"
    6. STDOUT.reopen "/dev/null", "a"
    7. STDERR.reopen "/dev/null", "a"

    View full-size slide

  21. 1. exit if fork
    2. Process.setsid
    3. exit if fork
    4. Dir.chdir "/"
    5. STDIN.reopen "/dev/null"
    6. STDOUT.reopen "/dev/null", "a"
    7. STDERR.reopen "/dev/null", "a"

    View full-size slide

  22. 1. exit if fork
    2. Process.setsid
    3. exit if fork
    4. Dir.chdir "/"
    5. STDIN.reopen "/dev/null"
    6. STDOUT.reopen "/dev/null", "a"
    7. STDERR.reopen "/dev/null", "a"

    View full-size slide

  23. 1. exit if fork
    2. Process.setsid
    3. exit if fork
    4. Dir.chdir "/"
    5. STDIN.reopen "/dev/null"
    6. STDOUT.reopen "/dev/null", "a"
    7. STDERR.reopen "/dev/null", "a"

    View full-size slide

  24. 1. exit if fork
    2. Process.setsid
    3. exit if fork
    4. Dir.chdir "/"
    5. STDIN.reopen "/dev/null"
    6. STDOUT.reopen "/dev/null", "a"
    7. STDERR.reopen "/dev/null", "a"

    View full-size slide

  25. 1. exit if fork
    2. Process.setsid
    3. exit if fork
    4. Dir.chdir "/"
    5. STDIN.reopen "/dev/null"
    6. STDOUT.reopen "/dev/null", "a"
    7. STDERR.reopen "/dev/null", "a"

    View full-size slide

  26. [email protected]
    @jlecour
    jeremy.wordpress.com
    github.com/jlecour

    View full-size slide