Skip to main content

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

Project description

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

# @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()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

sys_prctl-0.0.4-cp310-cp310-manylinux2014_x86_64.whl (64.4 kB view hashes)

Uploaded CPython 3.10

sys_prctl-0.0.4-cp310-cp310-manylinux2014_aarch64.whl (62.4 kB view hashes)

Uploaded CPython 3.10

sys_prctl-0.0.4-cp39-cp39-manylinux2014_x86_64.whl (63.6 kB view hashes)

Uploaded CPython 3.9

sys_prctl-0.0.4-cp39-cp39-manylinux2014_aarch64.whl (62.5 kB view hashes)

Uploaded CPython 3.9

sys_prctl-0.0.4-cp38-cp38-manylinux2014_x86_64.whl (63.5 kB view hashes)

Uploaded CPython 3.8

sys_prctl-0.0.4-cp38-cp38-manylinux2014_aarch64.whl (62.4 kB view hashes)

Uploaded CPython 3.8

sys_prctl-0.0.4-cp37-cp37m-manylinux2014_x86_64.whl (63.2 kB view hashes)

Uploaded CPython 3.7m

sys_prctl-0.0.4-cp37-cp37m-manylinux2014_aarch64.whl (62.8 kB view hashes)

Uploaded CPython 3.7m

sys_prctl-0.0.4-cp36-cp36m-manylinux2014_x86_64.whl (63.2 kB view hashes)

Uploaded CPython 3.6m

sys_prctl-0.0.4-cp36-cp36m-manylinux2014_aarch64.whl (62.9 kB view hashes)

Uploaded CPython 3.6m

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page