OS. fork (), OS. fork

Source: Internet
Author: User

OS. fork (), OS. fork

 

Ret = OS. fork () if ret = 0: child_suite # sub-process code else: parent_suite # parent Process Code

The fork () function in Python can obtain the PID (Process ID) of the Process in the system. If 0 is returned, it is a sub-Process. Otherwise, it is the parent Process, and then the running Process can be operated accordingly;

However, powerful fork () functions cannot be used in Python of Windows... It can only be used in Linux systems, such as Ubuntu 15.04. getpid () can be used to obtain the parent process ID in Windows ().

The following other OS. functions cannot be used in Windows:

Uname (), Obtain system information (host name, operating system version, patch level, system architecture, etc)
Getuid (), GET/set the real User ID of the current process
Getgid (), GET/set the group ID of the current process
Getsid (), Obtain the session ID or create and return a new SID.
Geteuid (), GET/set the valid user ID (GID) of the current process)
Getegid (), Obtain/set the group ID (GID) of the current process)
Getpgid (), Get/set process GID process PID: For get, if pid is 0, the current process GID is returned
Getlogin (), Returns the user logon result of the current process.
Getloadavg (); Returns the ancestor of the average system load value in the past 1, 5, and 15 minutes.

 

This is why most Server clusters are deployed in Linux, not only because the applications are deployed in Linux in a stable and smooth system, but more importantly, the functions of various tool sdks are improved.

 

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.