I'm getting acquainted with signals in C. I can't figure out what kind of signals SIGUSR1
and SIGUSR2
are and how can I trigger them. Can anyone please explain it to me?
相关问题
- Multiple sockets for clients to connect to
- What is the best way to do a search in a large fil
- glDrawElements only draws half a quad
- Index of single bit in long integer (in C) [duplic
- Equivalent of std::pair in C
They are signals that application developers use. The kernel shouldn't ever send these to a process. You can send them using
kill(2)
or using the utilitykill(1)
.If you intend to use signals for synchronization you might want to check real-time signals (there's more of them, they are queued, their delivery order is guaranteed etc).
They are user-defined signals, so they aren't triggered by any particular action. You can explicitly send them programmatically:
where
pid
is the process id of the receiving process. At the receiving end, you can register a signal handler for them:terminal 1
terminal 2
go back to terminal 1