python中的os abort_Python os.abort()用法及代码示例
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()用法及代码示例相关推荐
- python中的scale_Python Matplotlib.pyplot.yscale()用法及代码示例
Matplotlib是Python中的一个库,它是NumPy库的数字-数学扩展. Pyplot是Matplotlib模块的基于状态的接口,该模块提供MATLAB-like接口. matplotlib. ...
- python中squeeze函数_Python numpy.squeeze()用法及代码示例
当我们要从数组形状中删除一维条目时,将使用numpy.squeeze()函数. 用法: numpy.squeeze(arr, axis=None ) 参数: arr :[数组]输入数组. axis : ...
- python中argmin函数_Python numpy.argmin()用法及代码示例
numpy.argmin(array,axis = None,out = None):返回特定轴上数组min元素的索引. 参数: array:Input array to work on axis : ...
- python中offset_python pandas tseries.offsets.DateOffset用法及代码示例
用于日期范围的标准日期增量类型. 就您传入的关键字args而言,其工作方式与relativedelta完全相同,不建议使用关键字n-最好在使用的关键字中指定n,但无论它是否适合您. DateOffse ...
- python中set index_python pandas DataFrame.set_index用法及代码示例
使用现有列设置DataFrame索引. 使用一个或多个现有列或数组(长度正确)设置DataFrame索引(行标签).索引可以替换现有索引或在其上扩展. 参数: keys:label 或 array-l ...
- python中type(12.34)_Python typing.TYPE_CHECKING属性代码示例
本文整理汇总了Python中typing.TYPE_CHECKING属性的典型用法代码示例.如果您正苦于以下问题:Python typing.TYPE_CHECKING属性的具体用法?Python t ...
- python的datetime举例_Python datetime.timedelta()用法及代码示例
Python timedelta()函数存在于datetime库中,该函数通常用于计算日期差,也可以用于Python中的日期操作.这是执行日期操作的最简单方法之一. 用法: datetime.time ...
- python json dumps 自定义_Python json.dumps()用法及代码示例
JSON的完整形式是JavaScript Object Notation.这意味着将使用编程语言的文本组成的脚本(可执行)文件用于存储和传输数据. Python通过名为内置的软件包支持JSONjson ...
- python axes get_Python Matplotlib.axes.Axes.get_yaxis()用法及代码示例
Matplotlib是Python中的一个库,它是数字的-NumPy库的数学扩展.轴类包含大多数图形元素:Axis,Tick,Line2D,Text,Polygon等,并设置坐标系. Axes实例通过 ...
最新文章
- 如何更好地玩转GitHub?
- Context-----Activity,Application之间的交流使者
- python 下载阿里云mysql的备份文件及binlog到本地
- Java_注解 反射 字节码 类加载机制
- 【ARC103D】Distance Sums【树论】【构造】
- Java软件项目开发命名规范_命名规则
- 奇奇怪怪的知识增加了,大括号的历史你知道吗?
- Android RenderScript 关于Compute 的使用
- linux 快捷matlab_ubuntu下Matlab_Linux添加工具包操作步骤
- 压缩文件后,每次的HASH值(MD5)都不相同的原因
- 致敬Github那些卓越贡献的大佬和他们的公众号
- QT下使用MapX控件的问题以及Activex技术
- 单片机控制无线传输模块nRF905之模块化编程
- Android快捷开关实现
- win10 android叹号,win10网络连接感叹号如何解决
- 2020美容师(初级)模拟考试及美容师(初级)复审模拟考试
- 和平精英服务器响应超时什么意思,和平精英服务器无响应,和平精英服务器超时...
- GeoHash算法获取附近店铺和距离
- 解读两篇最新多元时间序列预测工作
- 树莓派3B/4B从零开始编译安装并刷入OpenWrt,让空闲的树莓派变成路由器
热门文章
- 科隆(Koln)一日游
- BCompare注册文件+密钥被撤销解决方案
- Myeclipse开发环境下文件中出现的提示错误与解决方法:The import javax.servlet cannot be resolved?
- ora-01033:oracle initialization or shutdown in progress 解决方法
- mysql字段默认值不生效的问题解决(上)
- Windows2008 R2下,DCOM配置里的属性灰色不可用的解决方法
- 使用字符串定界符(标准C ++)在C ++中解析(拆分)字符串
- 如何从Subversion存储库中git-svn克隆最后n个修订版?
- 仍在警告:配置“编译”已过时,并已由“实现”代替
- LintCode: Triangle