Metadata-Version: 2.1
Name: sys-prctl
Version: 0.0.4
Summary: sys_prctl: Linux syscall prctl setting the process name and the thread name
Home-page: https://github.com/ssbuild
Author: ssbuild
Author-email: 9727464@qq.com
License: Apache 2.0
Keywords: sys_prctl,prctl,python prctlsetproctitle,setprocname,setprotitle,setproname,processname,threadname,setprocessname,setprocess
Platform: linux_x86_64
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Education
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: C++
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Mathematics
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3, <4
Description-Content-Type: text/markdown

sys_prctl: Linux syscall prctl setting the process name and the thread name

```py
# @Time    : 2021/11/18 20:06
# @Author  : tk
# @FileName: test_prctl.py

import sys_prctl
import time
import os
'''
    sys_prctl: Linux syscall prctl setting the process name and the thread name
    
    sys_prctl had test pass at linux python3.6,python3.7,python3.8,python3.9
    
    support only for linux
'''


def test_prctl():
    # 参见linux prctl
    # sys_prctl.prctl
    pass
#set current process id
def test_process():
    #get process name
    name = sys_prctl.getprocname()
    print(name)

    # set process name
    name = "my_process"
    sys_prctl.setprocname(name)

    #get process name
    name = sys_prctl.getprocname()
    print(name)

    print(os.getpid())
    time.sleep(10 * 60)
    #ps -ef | grep my_process

def test_process_with_tid():
    #pthread_id is not thread id , it is c pthread id
    pthread_id = -1
    print('pthread_id:',pthread_id)
    # get process name
    name = sys_prctl.getprocname(pthread_id=pthread_id)
    print(name)

    # set process name
    name = "my_process"
    # tid thread id
    sys_prctl.setprocname(name, pthread_id=pthread_id)

    # get process name
    name = sys_prctl.getprocname(pthread_id=pthread_id)
    print(name)

    print(os.getpid())
    time.sleep(10 * 60)



    #ps -ef | grep my_process

if __name__ == '__main__':
    test_process()
```


