C- SIGUSR1在语法上到底是什么 [英] C- what exactly is SIGUSR1 syntactically

查看:223
本文介绍了C- SIGUSR1在语法上到底是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在kill()或signal()函数中使用SIGUSR1时,它在做什么?是宏吗?我读到它是用户定义的,但是它在哪里定义?我可以制作SIGUSR10(或以编程方式制作不同信号类型的阵列")吗?

When I use SIGUSR1 in the kill() or signal() functions, what is it doing? Is it a macro? I read that it was user defined, but where is it defined? Can I make a SIGUSR10 (or programatically make an "array" of different signal types)?

推荐答案

用户定义的信号意味着与SIGSEGVSIGCONTSIGSTOP等不同,这些信号没有明确的含义.内核将永远不会发送SIGUSR1或SIGUSR2是一个进程,因此您可以根据应用程序的需要来设置信号的含义.所有这些大写的SIG常量实际上都是宏,在特定的实现中,它们将扩展为指示信号编号的整数.尽管不一定要定义用户定义的信号,但信号编号已在特定实现中固定,并且可以安全地重新利用它们,因为除了用户以外,其他任何人都不会发送它们

User defined signals means that these signals have no definite meaning unlike SIGSEGV, SIGCONT, SIGSTOP, etc. The kernel will never send SIGUSR1 or SIGUSR2 to a process, so the meaning of the signal can be set by you as per the needs of your application. All these uppercase SIG constants are actually macros which will expand to an integer indicating a signal number in the particular implementation. Although user defined signals do not necessarily need to be defined, the signal numbers are already fixed in a particular implementation, and they can be safely re-purposed since they will not be sent by anything except for the user.

传统上,有两个用户定义的信号:SIGUSR1SIGUSR2.但是,最近的实现有一种叫做"POSIX实时信号"的东西,它提供了更多的用户定义的信号.

Traditionally, there have been two user-defined signals: SIGUSR1 and SIGUSR2. However, recent implementations have something called "POSIX realtime signals" which offer several more user-defined signals.

这篇关于C- SIGUSR1在语法上到底是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆