Server Administration

  Home arrow Server Administration arrow Page 3 - Processes in the UNIX Shell
SERVER ADMINISTRATION

Processes in the UNIX Shell
By: Gabor Bernat
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 3
    2009-11-18

    Table of Contents:
  • Processes in the UNIX Shell
  • Data about processes
  • Process Identifiers
  • Jobs

  •  
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    advertisement

    Processes in the UNIX Shell - Process Identifiers


    (Page 3 of 4 )

    The system assigns to every process an integer number that is called the process id (or pid). With this it can easily identify any process running. Knowing the number of a process, we can ask the kernel to give us any other information about the process, and also send signals to the process, as we will see later on.

    Starting a process inside UNIX is only possible by using another process. This way, every process belongs to another process and every child process will have a parent process. When the system starts up and the kernel starts to build the OS, it will first start a process entitled “init.” This will start the process that will take care of the time slice operation and distribution/schedule of processes for the CPU times.

    We refer to this process most of the time as the number 0 process. Its name differs from OS to OS; however, it is one off from the sched, swapper, and kernel. The ps command will not list this. This way, the first real process is the init to which the number 1 process identifier is assigned. All other processes will be started by the init or a child of this. Draw this on a sketch and you will have a tree like structure. With the pstree command inside a terminal you can view exactly this:

    Following this rule, a shell script we start from a terminal will also be the child of the terminal, and the script itself will be a process on its own. Inside a shell script, the process identifier of the script is stored in the $$ special variable.

     

    #!/bin/bash

    echo $$

    This will print the process identifier of the script. Observe that this is a different number each time you start the script. This is due the fact that numbers are assigned one after another for every process, and this is always unique. There aren’t two with the same pid in the same time.

    More Server Administration Articles
    More By Gabor Bernat

    blog comments powered by Disqus

    SERVER ADMINISTRATION ARTICLES

    - Server Responses to Client Communication
    - Authentication in Client/Server Communication
    - Client/Server Communication
    - Understanding Awk in the UNIX Shell
    - Stream Editor in the UNIX Shell
    - Processes in the UNIX Shell
    - Migrating from Windows to Wine
    - Wine: Not Another Emulator
    - Preventive Measures to Block SSH Attacks
    - Monitoring Temperatures with Cacti
    - Cacti: RRDTool-based Graphing Solution
    - Network Magic 5.0 Review
    - Netfilter and Iptables Overview
    - Installing and Configuring Squid
    - Clickfree PC Backup Systems Compared


    © 2003-2012 by Developer Shed. All rights reserved. DS Cluster 9 - Follow our Sitemap