本文整理汇总了Python中General.getrealuid方法的典型用法代码示例。如果您正苦于以下问题:Python General.getrealuid方法的具体用法?Python General.getrealuid怎么用?Python General.getrealuid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类General
的用法示例。
在下文中一共展示了General.getrealuid方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_self_oom_target_linux
# 需要导入模块: import General [as 别名]
# 或者: from General import getrealuid [as 别名]
def make_self_oom_target_linux():
"""Make the current process the primary target for Linux out-of-memory killer"""
# In Linux 2.6.36 the system changed from oom_adj to oom_score_adj
path = "/proc/%d/oom_score_adj" % os.getpid()
if os.path.exists(path):
open(path, "w").write("1000")
else:
path = "/proc/%d/oomadj" % os.getpid()
if os.path.exists(path):
open(path, "w").write("15")
# OOM likes nice processes
print "debug: new nice value", os.nice(19)
# OOM prefers non-privileged processes
try:
uid = General.getrealuid()
if uid > 0:
print "debug: dropping privileges of pid %d to uid %d" % (os.getpid(), uid)
os.seteuid(uid)
except:
traceback.print_exc()