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 addressesArgv
OrEnviron
Array, so that the process of the original program is not affected. 2. We canAgv
The first place andEnviron
At the end of the graph, set the content you want to display../Exe
Start Point andEnv5 = val5
The 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 ......