Set the process name

Source: Internet
Author: User

Set the process name

Http://luoguochun.cn/2014/07/04/set-proccess-title/

 

How to Develop

When we usually run ps processes, the process title is the name of the program we entered and some parameters. This display method is not very intuitive. We need to set the program title in one way to know at a glance what the process is. For example, redis or nginx:

Root 8527 1 0 10: 30? 00:00:00 nginx: master process nginx 8528 8527 0? 00:00:00 nginx: worker process

The principle of zookeeper implementation is very simple. We only need to modify argv [0] and point to the content of the memory space. However, in order to keep the normal logic of the program unaffected, we must first save the content of the principle and access it through the original method.
The space that zookeeper argv [0] points to is continuous with the memory space that · enviorn · points to. When the program starts, the system has set these spaces. :

Zookeeper

Then, 1. We only need to re-allocate space (not necessarily continuous) to store the content and copy the addressesArgvOrEnvironArray, so that the process of the original program is not affected. 2. We canAgvThe first place andEnvironAt the end of the graph, set the content you want to display../ExeStart Point andEnv5 = val5The last Zero-ending point. You only need to note that the set content must end with 0 and cannot exceed the memory space.

How to Implement redis

Zookeeper redis is implemented in setproctitle. But the implementation is a bit confusing:

Simple tucao

Although redis is very famous for zookeeper, redis Code does not seem very standard ...... Or what we have been dealing with is not standardized, haha ......

Related Article

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.