我可以在没有线程的情况下使用 pthread_sigmask 吗?
Can I use pthread_sigmask without thread?
我已经共享了两个使用 pthread_sigmask 的可执行文件的代码。其中一个可执行文件具有 pthread 线程,另一个只是一个进程。可以在没有线程的情况下调用 pthread_sigmask 还是应该在第二种情况下使用 sigprocmask?
The pthread_sigmask() function shall examine or change (or both) the
calling thread's signal mask, regardless of the number of threads in
the process. The function shall be equivalent to sigprocmask(),
without the restriction that the call be made in a single-threaded
process.
In a single-threaded process, the sigprocmask() function shall examine
or change (or both) the signal mask of the calling thread.
来自 sigprocmask:
In a single-threaded process, the sigprocmask() function allows the calling process to examine or change (or both) the signal mask of the calling thread.
.....
The use of the sigprocmask() function is unspecified in a multi-threaded process.
一开始,每个进程都有一个线程,即 运行s main()
的线程。 sigprocmask()
只能在单线程进程中 运行。 pthread_sigmask()
在任意数量的线程进程中可以是 运行。
Can I use pthread_sigmask without thread?
是的。
Is it ok to call pthread_sigmask without thread or should I use sigprocmask in the second case?
没关系。
您标记了 linux
。大多数 linux
使用 glibc
,而在 glibc
中使用 pthread_sigmask() calls the same syscall rt_sigprocmask
or just the function sigprocmask()。所以在 glibc
他们做完全一样的事情。
我已经共享了两个使用 pthread_sigmask 的可执行文件的代码。其中一个可执行文件具有 pthread 线程,另一个只是一个进程。可以在没有线程的情况下调用 pthread_sigmask 还是应该在第二种情况下使用 sigprocmask?
The pthread_sigmask() function shall examine or change (or both) the calling thread's signal mask, regardless of the number of threads in the process. The function shall be equivalent to sigprocmask(), without the restriction that the call be made in a single-threaded process.
In a single-threaded process, the sigprocmask() function shall examine or change (or both) the signal mask of the calling thread.
来自 sigprocmask:
In a single-threaded process, the sigprocmask() function allows the calling process to examine or change (or both) the signal mask of the calling thread.
.....
The use of the sigprocmask() function is unspecified in a multi-threaded process.
一开始,每个进程都有一个线程,即 运行s main()
的线程。 sigprocmask()
只能在单线程进程中 运行。 pthread_sigmask()
在任意数量的线程进程中可以是 运行。
Can I use pthread_sigmask without thread?
是的。
Is it ok to call pthread_sigmask without thread or should I use sigprocmask in the second case?
没关系。
您标记了 linux
。大多数 linux
使用 glibc
,而在 glibc
中使用 pthread_sigmask() calls the same syscall rt_sigprocmask
or just the function sigprocmask()。所以在 glibc
他们做完全一样的事情。