You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Linux provides an API for blocking execution until a signal is received. This would be desirable in a program where most of the execution occurs in background threads and the main thread waits until it's time to shut down.
API Changes
For the sake of simplicity and flexibility, the function should allow the function to wait on multiple signums. This would add 3 new entries to the C API:
For the timed wait functions, it might make sense to introduce a new status code SIGFN_TIMEOUT instead of trying to populate the received value with a designated value to indicate no signal was received.
And 3 equivalent functions for the C++ API.
Implementation Suggestions
A straightforward way to do this would to recreate the signal handling pattern from golang:
package main
import (
"fmt""os""os/signal"
)
funcmain() {
// Set up channel on which to send signal notifications.// We must use a buffered channel or risk missing the signal// if we're not ready to receive when the signal is sent.c:=make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
// Block until a signal is received.s:=<-cfmt.Println("Got signal:", s)
}
This could be accomplished in the following steps:
Define a signal handler that writes the signum to a channel
Register a sigfn_handle for each signum in the set to invoke the handler
Receive the sigum from the channel in the main thread after it has been written by the interrupt handler
The text was updated successfully, but these errors were encountered:
Linux provides an API for blocking execution until a signal is received. This would be desirable in a program where most of the execution occurs in background threads and the main thread waits until it's time to shut down.
API Changes
For the sake of simplicity and flexibility, the function should allow the function to wait on multiple signums. This would add 3 new entries to the C API:
For the timed wait functions, it might make sense to introduce a new status code
SIGFN_TIMEOUT
instead of trying to populate thereceived
value with a designated value to indicate no signal was received.And 3 equivalent functions for the C++ API.
Implementation Suggestions
A straightforward way to do this would to recreate the signal handling pattern from golang:
This could be accomplished in the following steps:
sigfn_handle
for each signum in the set to invoke the handlerThe text was updated successfully, but these errors were encountered: