View FreeBSD Processes

Source: Internet
Author: User
FreeBSD is a multi-task operating system, that is, multiple programs can be executed at the same time. A program in execution is a process.

Each process has a unique identifier temporarily assigned by the system, known as the process ID (which can be allocated from 1 to 99999) or PID. Most processes have a parent process, that is, the process used to start the process. However, there is a process called init in the system, and its PID is always 1. The process is automatically started by the kernel at FreeBSD startup.

For example, if you execute the command ls in the shell, the process corresponding to the LS is the sub-process of the shell, and the shell is the parent process of the ls.

In FreeBSD, you can use the PS and top commands to view the status of processes in the current system. PS displays the status of the processes running with control terminals, including the PID, terminal, status, CPU usage, and command to start the processes. Common PS parameters include: A displays all running processes, u displays the users and memory occupied by the processes, X displays the background processes, and WW displays the complete command line.

Appendix: Some of the terminals in the process need to interact with users to complete their functions. The other part does not need to interact with users. It is called the daemon deamon (usually added with d after the name ).

Top displays all running processes, including PID, user running the process, number of running threads, priority, maximum memory requirement, current memory usage, Process status, CPU usage time and percentage, and the commands that run the process. In addition, the process will refresh the status every 2 seconds by default. This parameter can be modified with option S. At the beginning of the command, the current total number of processes, Process status statistics, CPU status, memory information, and swap partition information are displayed.

The signal mechanism can be used for inter-process communication. Different signals have different meanings based on different numbers. Some of them have special meanings, and others can be explained by applications. Generally, users can only send information to their own processes, while messages sent to others may be rejected by kill. However, root can send various signals to each process.

In some cases, FreeBSD can send signals to applications, such as SIGSEGV and sigalrm. The signals that can be used to terminate a process include sigterm and sigkill. The former can be determined by the process to determine whether to terminate the process. The process that receives the latter must be terminated immediately.

In FreeBSD, you can use the/bin/kill command to send signals. The syntax is:
Kill-S Signal PID

Common signals include hup, Int, quit, abrt, kill, alrm, and term.

Let's take a look at shell. Shell is the command line interface. Its main function is to obtain the command from the input and then execute it. FreeBSD contains several shells, such as SH and tcsh. You can choose which Shell to use (CSH by default ). A major feature of shell is that it can automatically complete the file name (enter the command or the first few letters of the file name and press the tab key. If the file name cannot be completely automatic, a bell is triggered ).

Another feature of shell is the use of environment variables, including user (current user name), path (default path name), display (Network Name of X11 display), shell (the current Shell Name), term (the name of the user terminal), termcap (basic data items for separating coding of terminals used by various terminal functions), ostype (operating system type) machtype (CPU architecture), editor (preferred text editor), pager (preferred text page scheduling schedule), and manpath (online manual path. The command for setting variables in CSH is:
Setenv variable name value

The command to display the environment variable value is:
Echo $ variable name

Reference: the FreeBSD documentation project

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.