To view FreeBSD processes

Source: Internet
Author: User

This paper turns from https://blog.csdn.net/dragonbbc/article/details/839899

FreeBSD is a multitasking operating system, which means you can execute multiple programs at the same time. A program in execution is a process.

Each process has a unique identity that is temporarily allocated by the system, called the process ID (available from 1 to 99999), or PID. The vast majority of processes have a parent process, which is the process used to start the process. However, there is a process called init in the system whose PID is always 1, which is started automatically by the kernel when FreeBSD is started.

For example, the user executes the instruction LS in the shell, then the LS-corresponding process is the shell's child process, and the shell is the parent process of LS.

In FreeBSD, you can use PS and top two directives to view the status of processes in the current system. Where PS displays the status of the process currently running with the control terminal, including PID, running its terminal, status, CPU time occupied, and the command to start it. PS commonly used parameters include: A show all running processes, u show the process belongs to the user and memory, x shows the background process, WW displays the complete command line.

Attached: In the process, there is a part of the terminal, need to interact with the user to complete its function. And the other part is that you do not need to interact with the user, called Daemon Deamon (usually after the name plus D).

Top displays all the running processes, including the PID, the user who ran the process, the number of threads running, the priority, the maximum memory requirements, the current memory footprint, process status, CPU time and percentage, and the commands to run the process. Also, the process defaults to a refresh of the state every 2 seconds, which can be modified with option S. At the beginning of the command, the current total number of processes, process status statistics, CPU state, memory information, and Exchange partition information are displayed.

Communication between processes can take the signaling mechanism. Different signals have different meanings depending on the number of numbers, some of which have special meaning and others can be explained by the application. Typically, users can only send information to the process they own, while messages sent to others may be rejected by kill. But Root can send a variety of signals to each process.

In some cases, FreeBSD can send signals to an application, such as a segment violation signal (SIGSEGV) and an alarm clock signal (SIGALRM). The signals that can be used to terminate a process are sigterm and Sigkill, which can be determined by the process itself or not, and processes that receive the latter must be terminated immediately.

In FreeBSD, you can use the/bin/kill directive to send a signal with the syntax:
Kill-s Signal PID

The commonly used signals include HUP, INT, QUIT, ABRT, KILL, ALRM, term, etc.

Look at the shell again. The shell is the command-line interface, whose main function is to get the command from the input and execute it. FreeBSD contains a number of shells, such as SH, tcsh, and so on, you can choose which shell to use (default is CSH). A big feature of the shell is the ability to automatically fill the file name (enter the command or file name after the first few letters press the TAB key, if you can not automatically give a ring if not all).

Another feature of the SHELL is the use of environment variables, mainly including user (current username), path (default path name), display (X11 display network name), Shell (currently used shell name), TERM (user terminal name), TERMCAP (separate encoded basic data items for terminals used by various terminal functions), OSType (operating system type), Machtype (CPU Architecture), EDITOR (preferred text editor), PAGER (preferred text page scheduler) Order) and Manpath (online manual path) and so on. The instructions for setting the variable under CSH are:
SETENV Variable Name value

Instructions for displaying the value of an environment variable are:
echo $ variable Name

References: 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.