File tree Expand file tree Collapse file tree 3 files changed +10
-5
lines changed Expand file tree Collapse file tree 3 files changed +10
-5
lines changed Original file line number Diff line number Diff line change
1
+ Allow use of ` SignalFd ` through shared reference
2
+
3
+ Like with many other file descriptors, concurrent use of signalfds is safe.
4
+ Changing the signal mask of and reading signals from a signalfd can now be done
5
+ with the ` SignalFd ` API even if other references to it exist.
Original file line number Diff line number Diff line change @@ -105,11 +105,11 @@ impl SignalFd {
105
105
Ok ( SignalFd ( fd) )
106
106
}
107
107
108
- pub fn set_mask ( & mut self , mask : & SigSet ) -> Result < ( ) > {
108
+ pub fn set_mask ( & self , mask : & SigSet ) -> Result < ( ) > {
109
109
self . update ( mask, SfdFlags :: empty ( ) )
110
110
}
111
111
112
- pub fn read_signal ( & mut self ) -> Result < Option < siginfo > > {
112
+ pub fn read_signal ( & self ) -> Result < Option < siginfo > > {
113
113
let mut buffer = mem:: MaybeUninit :: < siginfo > :: uninit ( ) ;
114
114
115
115
let size = mem:: size_of_val ( & buffer) ;
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ fn read_empty_signalfd() {
28
28
} ;
29
29
30
30
let mask = SigSet :: empty ( ) ;
31
- let mut fd = SignalFd :: with_flags ( & mask, SfdFlags :: SFD_NONBLOCK ) . unwrap ( ) ;
31
+ let fd = SignalFd :: with_flags ( & mask, SfdFlags :: SFD_NONBLOCK ) . unwrap ( ) ;
32
32
33
33
let res = fd. read_signal ( ) ;
34
34
assert ! ( res. unwrap( ) . is_none( ) ) ;
@@ -47,7 +47,7 @@ fn test_signalfd() {
47
47
mask. add ( signal:: SIGUSR1 ) ;
48
48
mask. thread_block ( ) . unwrap ( ) ;
49
49
50
- let mut fd = SignalFd :: new ( & mask) . unwrap ( ) ;
50
+ let fd = SignalFd :: new ( & mask) . unwrap ( ) ;
51
51
52
52
// Send a SIGUSR1 signal to the current process. Note that this uses `raise` instead of `kill`
53
53
// because `kill` with `getpid` isn't correct during multi-threaded execution like during a
@@ -72,7 +72,7 @@ fn test_signalfd_setmask() {
72
72
// Block the SIGUSR1 signal from automatic processing for this thread
73
73
let mut mask = SigSet :: empty ( ) ;
74
74
75
- let mut fd = SignalFd :: new ( & mask) . unwrap ( ) ;
75
+ let fd = SignalFd :: new ( & mask) . unwrap ( ) ;
76
76
77
77
mask. add ( signal:: SIGUSR1 ) ;
78
78
mask. thread_block ( ) . unwrap ( ) ;
You can’t perform that action at this time.
0 commit comments