此功能将信号发送到进程列表。返回成功发出信号的进程数。
如果SIGNAL为零,则没有信号发送到该进程。这是检查子进程是否仍在运行且未更改其UID的有用方法。支持的信号的精确列表完全取决于系统实现-
Name Effect SIGABRT Aborts the process SIGARLM Alarm signal SIGFPE Arithmetic exception SIGHUP Hang up. SIGILL Illegal instruction SIGINT Interrupt SIGKILL Termination signal SIGPIPE Write to a pipe with no readers. SIGQUIT Quit signal. SIGSEGV Segmentation fault SIGTERM Termination signal SIGUSER1 Application-defined signal 1 SIGUSER2 Application-defined signal 2
以下是此函数的简单语法-
kill EXPR, LIST
此函数返回成功发出信号的进程数。
以下是显示其基本用法的示例代码-
链接:https://www.learnfk.comhttps://www.learnfk.com/perl/perl-kill.html
来源:LearnFk无涯教程网
#!/usr/bin/perl $cnt = kill 0, getppid(), getpgrp(), 2000; print "Signal sent to $cnt process\n";
执行上述代码后,将产生以下输出-
Signal sent to 2 process
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)