Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Program specification of reading notes for LINUX high-performance server

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Background: in addition to network communication, the server program has many details.

Features: the details are templated, so you just need to be clear and follow certain norms.

Category: 1.1 running form-> background process, also known as guard process. There is no control terminal, and it will not be accidentally input by the user.

Its parent process is the init process (pid is a 1 process)

1.2 Chronicle system. Generally, at least output to a file, can also be exported to a dedicated UDP server. Generally, you have your own log directory in / var/log.

1.3 running identity: a specific non-root identity. Example: daemons such as mysqld,httpd,syslogd have their own accounts mysql,apache,syslog

1.4 Configurable. Can handle a lot of command line options. If there are too many options to run at once, a configuration file is required to manage it. It is usually put on / etc. For example, squid in / etc/squid3/squid.conf

1.5 record the pid of the background process. Startup will generate a pid file and save it to / var/run. Example: the pid file for syslogd is / var/run/syslogd.pid

1.6 consider system resources and limitations (own maximum load) examples: the total number of file descriptors and the total amount of memory.

Linux detail handling method

2.1log: rsyslogd (syslog function)

2.2 user information: UID,EUID (valid user ID), GID,EGID

EUID: facilitate access to resources. Purpose: it enables the user running the program to have the privileges of a valid user of the program. (su program, su must visit / etc/passwd to change user information. / etc/passwd requires root permission, so ordinary users must rely on EUID to access it. The owner can set the set-user-id of his own program, and the command is: chmod + s * program)

2.3.1linux each process belongs to a process group. In addition to pid and PGID, each process group has a leader process. The pid and PGID of the leader process are the same. 2.3.2 the process group will always exist. It is terminated when all of these processes exit or join other groups. 2.3.3 A process can only set its own or its child's {PGID. When a child process calls a series of exec functions, the parent process can no longer set its PGID. 2.4 session 2.4.1 definition: some associated process groups will form a session\\ implementation: non-leader processes can call this function to create a new session. Implementation features: the calling process becomes the leader of the session, and the process is the only member of the new session. Create a new process group whose PGID is the PID of the calling process, and the calling process is the leader of the group. The calling process will leave the terminal function: pid_t setsid (void); characteristic: no sid,linux considers it to be equal to the PGID,pid_t getsid (pid_t pid) of the process group in which the session leader belongs. 2.5 system resource limit 2.6 change the working directory and root directory 2.6.1 function: get the current working directory and change the process working directory char* getcwd (char* buf,size_t size) Int chdir (const char* path) function 2: change the process root directory chroot int chroot (const char* path) 2.7.1 Service program backstage linux library function int deamon (int nochdir,int noclose) Parameter nochdir: whether to change the working directory; 0 is the root directory, otherwise use the current directory, noclose is 0, standard input and standard output and standard error output will be redirected to the / dev/null file, otherwise the original device will still be used. The function successfully returns 0. 0. Failed to return-1

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report