dom.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:dom 作者: aristanetworks 项目源码 文件源码
def set_proc_name(newname):
    '''Set the process name seen by the OS in ps, for example
    '''
    log("Entering {0}.".format(sys._getframe().f_code.co_name), level='DEBUG')

    # This works on EOS but not on OSX.  Wrapped in try for testability.
    try:
        libc = cdll.LoadLibrary('libc.so.6')
        buff = create_string_buffer(len(newname) + 1)
        buff.value = newname
        libc.prctl(15, byref(buff), 0, 0, 0)
    except:
        log("Unable to set process name", level='DEBUG')

    if DEBUG:
        print "proc_name: {0}\n".format(sys.argv[0])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号