Introduction
People who work with shell are familiar with shell programming in Unix/Linux. # is mentioned in all shell programming books #! /Bin/bash. What exactly does it contain? What does this string mean for the operating system? You may say,
In the previous section, I found a general example on the network for you. Next I will gradually change the code into reusable code available in conventional development.
First, let's talk about the problems encountered by the above Code in actual
Linux system programming: Process primitives, linux programming process primitives
Process primitives
1. Process is a running activity of a program on a dataset in a computer. It is the basic unit for the system to allocate and schedule resources
Process Control (2) competitive conditions
When multiple processes attempt to process shared data in a certain way, and the final result depends on the order in which the process runs, we think this is a competitive condition.
If a parent process
All current UNIX Systems Support interpreter files) (Also known as interpreter script ). This type of file is:
The space between the exclamation point and pathname is optional. The most common interpreter file starts with the following columns:
#! /
Interactive programs usually require users to manually complete some operations, which often becomes an obstacle in system management automation and test automation. The least CT language that appeared on Unix can be used to interact with command
It is called by the exec system. In fact, in Linux, there is no exec () function form. Exec refers to a group of functions, with a total of six functions:
# Include Int execl (const char * path, const char * Arg ,...);Int execlp (const
1. Fork + Exec
Fork is used to create a child process. When a program calls the fork function, the system prepares the preceding three segments for a new process. First, the system allows the new process and the old process to use the same code
REGEXP (regular Expression) objectA regular expression is an object that describes a character pattern and can handle more complex strings. Make a match substitution.Common modifiers:I/m/gHow to use:"Declaration method One: New RegExp (value)"var
These two days to learn something a little more, feel completely coping but come, have been digesting these days to learn things so 2 ,3 ,4 of the study content did not summarize in a timely manner, In this expressed deep guilt, today to learn these
Linux Kernel Analysis Sixth Week study summary--description of the process and creation of the processZhang Yi (Original works reproduced please specify the source)"Linux kernel Analysis" MOOC course http://mooc.study.163.com/course/USTC-1000029000I.
2. process initiation and termination2.1 C Program startup Process(1) Start-up routines① is a program code that is placed in the/lib/libc.so.***. at compile time, the compiler compiles the code for the startup routine into the executable file .The ②
Some of the content is from: Linux Kernel Development (third Edition), Robert love, Chen Li June and other translations.1. ProcessA process is a real-time result of an executing program code that contains an open file, a pending signal, and so on. A
Function Description: This function is to specify your string for a match detection, get the contents of the first and regular expression in the string, and the matching content and the results of the child match in the return array
Basic method:
Process Control:1, Process creation function: fork ();Header file:#include #include Function Prototypes:pid_t fork (void);function return Value: 0: Indicates that this process is now a child process;-1: Indicates an error;The child process ID number,
EXEC () function family:Let's take a look at how a process starts and a program runs. You want to use the EXEC function family in Linux. The system calls EXECVE () to replace the current process with a specified program whose parameters include the
1. Creation of processesThere are four types of functions that create sub-processes under Linux: System (), fork (), exec* (), Popen ()1.1. System functionsPrototype: #include int system (const char *string); The system function executes the
11, Process creationLinux process creation can be divided into two steps, the fork () and the Exec () function, fork () is responsible for creating a child process, and the parent process is only the PID ppid and some statistics, the EXEC ()
Experimental Purpose:Use GDB to track the processing of SYS_EXECVE kernel functions, analyze the system call processing of the exec* function, and understand how the Linux kernel loads and launches an executable program.Experimental steps:Open the
Basic Operations Command:
PS-AJX/-AUX/-EF view inter-process status/relationships
Top dynamic display of processes in the system
Nice run/renice by the specified priority change the priority of the running process
Kill-9 Kill Process
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.