Skip to content

Update man page for makeSignalSource#560

Open
Frizlab wants to merge 1 commit intoswiftlang:mainfrom
Frizlab:patch-1
Open

Update man page for makeSignalSource#560
Frizlab wants to merge 1 commit intoswiftlang:mainfrom
Frizlab:patch-1

Conversation

@Frizlab
Copy link
Copy Markdown

@Frizlab Frizlab commented Apr 15, 2021

The following test on Linux shows the doc was not up-to-date for Linux:

var newAction = sigaction()
newAction.sa_flags = SA_SIGINFO
sigemptyset(&newAction.sa_mask)
newAction.__sigaction_handler.sa_sigaction = { signal, siginfo, threadUserContext in
	print("got \(signal) from sigaction")
}
sigaction(15, &newAction, nil)
let s = DispatchSource.makeSignalSource(signal: 15)
s.setEventHandler{
	print("got \(s.data) signal 15 from dispatch")
}
s.activate()
usleep(5000)
kill(getpid(), 15)
sleep(1)

Expected output: got signal from both sigaction and dispatch.
Actual output: got signal from dispatch only.

If we run the test on macOS, we do get the signal from both sources.
If the dispatch source is not activated, we do get the signal from sigaction on Linux.

Tested on Docker, using the swift:5.3.3 image and macOS 11.

The following test on Linux shows the doc was not up-to-date for Linux:
```
var newAction = sigaction()
newAction.sa_flags = 0
sigemptyset(&newAction.sa_mask)
newAction.__sigaction_handler.sa_sigaction = { signal, siginfo, threadUserContext in
	print("got \(signal) from sigaction")
}
sigaction(15, &newAction, nil)
let s = DispatchSource.makeSignalSource(signal: 15)
s.setEventHandler{
	print("got \(s.data) signal 15 from dispatch")
}
s.activate()
usleep(5000)
kill(getpid(), 15)
sleep(1)
```

**Expected output**: `got signal` from both `sigaction` and `dispatch`.
**Actual output**: `got signal` from `dispatch` only.

If we run the test on macOS, we do get the signal from both sources.
If the dispatch source is not activated, we do get the signal from `sigaction` on Linux.

Tested on Docker, using the `swift:5.3.3` image and macOS 11.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant