Python中的OS模塊提供了與操作係統進行交互的功能。操作係統屬於Python的標準實用程序模塊。該模塊提供了使用依賴於操作係統的功能的便攜式方法。

os.abort()Python中的方法用於生成到當前進程的SIGABRT信號。在Unix上,此方法產生一個核心轉儲,而在Windows上,該過程立即返回退出代碼3。此方法不使用signal.signal()調用為SIGABRT信號注冊的Python信號處理程序。

用法: os.abort()

參數:不需要任何參數。

返回類型:此方法在調用過程中不返回任何值。

代碼1:用於os.abort()方法

# Python program to explain os.abort() method

# importing os module

import os

print("Hello ! Geeks")

# os.abort() method

# will generate 'SIGABRT'

# signal to the current process

# On Unix, a core dump

# will be produced

# On windows, process

# will exit with exit code 3

os.abort()

# As process is aborted

# the line after os.abort() statement

# will not be executed.

print("This will not be printed")

輸出:

Hello! Geeks

Aborted (core dumped)

代碼2:用於os.abort()方法

# Python program to explain os.abort() method

# importing os module

import os, signal

# Create a child process

# using os.fork() method

pid = os.fork()

# pid greater than 0

# indicates the parent process

if pid > 0:

# Parent process

print("\nIn Parent process")

# Wait for the completion

# of child process and get

# its pid and exit status indication

# using os.wait() method

info = os.wait()

sig = os.WTERMSIG(info[1])

print("Child exited due to signal no:", sig)

print("Signal name:", signal.Signals(sig).name)

else :

# child process

print("In child process")

print("Process ID:", os.getpid())

print("Hello ! Geeks")

# Abort the child process

# by generating SIGABRT signal

# using os.abort() method

os.abort()

輸出:

In child process

Process ID: 13914

Hello! Geeks

In Parent process

Child stopped due to signal no: 6

Signal name: SIGABRT

python中的os abort_Python os.abort()用法及代碼示例相关推荐

  1. python中fmod什么意思_Python fmod()用法及代碼示例

    fmod()函數是Python中的標準數學庫函數之一,用於計算指定給定參數的模塊. 用法: math.fmod( x, y ) 參數: x任何有效數字(正數或負數). y任何有效數字(正數或負數). ...

  2. python strftime时分秒_Python time.strftime()用法及代碼示例

    由於時間模塊提供了各種與時間有關的功能.因此,有必要導入時間模塊,否則將由於時間的定義而出錯.時間模塊中存在strftime(format [,t]). time.strftime(format[, ...

  3. java中的case1怎么说_Java Cas20ServiceTicketValidator類代碼示例

    本文整理匯總了Java中org.jasig.cas.client.validation.Cas20ServiceTicketValidator類的典型用法代碼示例.如果您正苦於以下問題:Java Ca ...

  4. java中reject方法作用_Java BindingResult.rejectValue方法代碼示例

    本文整理匯總了Java中org.springframework.validation.BindingResult.rejectValue方法的典型用法代碼示例.如果您正苦於以下問題:Java Bind ...

  5. python中sinh是什么_Python numpy.sinh()用法及代碼示例

    numpy.sinh(x [,out])= ufunc'sin'):此數學函數可幫助用戶計算所有x(作為數組元素)的雙曲正弦值. 等效於1/2 *(np.exp(x)-np.exp(-x))或-1j ...

  6. python calendar.isleap_Python calendar isleap()用法及代碼示例

    日曆模塊允許輸出類似於程序的日曆,並提供與日曆相關的其他有用功能. "日曆"模塊中定義的函數和類使用理想化的日曆,當前的公曆日曆在兩個方向上都無限期擴展. 在Python中,cal ...

  7. Python学习笔记 Matplotlib.colors.Normalize用法及代碼示例

    Matplotlib是Python中令人驚歎的可視化庫,用於數組的二維圖. Matplotlib是一個基於NumPy數組的多平台數據可視化庫,旨在與更廣泛的SciPy堆棧配合使用. matplotli ...

  8. randint用法 python_Python randint()用法及代碼示例

    randint()是Python3中隨機模塊的內置函數.隨機模塊提供對各種有用功能的訪問,其中一個功能可以生成隨機數,即randint().句法: randint(start, end) 參數: (s ...

  9. java中decrement,Java LongAdder decrement()用法及代碼示例

    Java中的LongAdder類創建一個初始和為零的新加法器. Java.LongAdder.decrement()是Java中的內置方法,可將值減少1. 用法: public void decrem ...

最新文章

  1. java pages_Java Server Pages 内置对象
  2. 用python画爱心的代码-Python一行代码画个爱心案例
  3. python装饰器实例-Python装饰器简单用法实例小结
  4. mysql 自动热备份_mysql(mariadb)定时自动热备份+增量+远程备份脚本
  5. Mongodb实战使用指南
  6. 如何解析lvx文档_建站零基础入门:手把手教你如何自助建站
  7. cf1557D. Ezzat and Grid
  8. 领域驱动设计模式设计与实践_在域驱动设计中使用状态模式
  9. RefineMask:实例分割,使用细粒度信息增强性能
  10. sqlmap指定cookie_sqlmap处理cookie数据
  11. jQuery解决iframe高度自适应的一例代码
  12. c/c++线性循环队列
  13. 华硕笔记本电池软件_成色配置都还不错的二手华硕7代 i5 笔记本电脑 只卖1599元 想要的 快进来看看...
  14. RFB-Net论文代码映射
  15. js中将从ajax获得的时间戳数字串转换成理解的时间格式
  16. 长短视频平台内卷自制剧,网剧制作商耐看娱乐能“耐看”吗?
  17. VIBE运动目标检测算法实现
  18. Android 底部导航栏 BottomNavigationBar
  19. SpringCloud:统一网关Gateway
  20. chrome如何手动同步?

热门文章

  1. 一天搞定CSS: 浮动(float)的副作用--12
  2. r语言glmnet包系数显示不全_第一章: R语言介绍
  3. json数据格式 python_python中json是什么文件格式
  4. 阿里云MySQL远程登录异常
  5. Java里的接口的interface 简单介绍.
  6. java cindy_java枚举应用
  7. 权限管理系统中 管理员能看到所有用户的密码么_计算机毕设项目002之学生成绩管理系统...
  8. java递归方法调用自己_java – 同步方法调用自身递归 这破了吗
  9. html倒计时timer,JavaScript定时器设置、使用与倒计时案例详解
  10. 广州站 | 云原生 Serverless 技术实践营精彩回顾