进程炸弹运行截图
这是一个用python实现的最简单的fork炸弹
import os
while True:
os.fuck()
fork
函数的,幸运的是,python提供了multiprocessing
实现了跨平台的方法,对线程进行操作以下程序仅供学习之用,为避免对系统的造成损伤,已经进行了延时处理
from multiprocessing import Process
import os
import time
G_boom_num = 1
def boom():
print("炸弹的进程号为%d"%os.getpid())
pass
# 主函数
def main():
global G_boom_num
while True:
# 创建一个炸弹(子进程)
bo = Process(target = boom)
# 引爆炸弹...
bo.start()
# 为炸弹计数
G_boom_num += 1
print("创建第%d个炸弹"%G_boom_num)
# 创建一个炸弹后延时2秒钟,如果想试试进程炸弹的威力,可以把下面这行注释掉...
time.sleep(2)
# 开启入口,启动主程序
if __name__ == "__main__":
main()
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有