1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 04:47:35 +00:00

Userland et al: Pledge sigaction when needed

* In some cases, we can first call sigaction()/signal(), then *not* pledge
  sigaction.
* In other cases, we pledge sigaction at first, call sigaction()/signal()
  second, then pledge again, this time without sigaction.
* In yet other cases, we keep the sigaction pledge. I suppose these could all be
  migrated to drop it or not pledge it at all, if somebody is interested in
  doing that.
This commit is contained in:
Sergey Bugaev 2020-05-26 13:52:42 +03:00 committed by Andreas Kling
parent cddaeb43d3
commit 4139838a93
9 changed files with 38 additions and 37 deletions

View file

@ -36,11 +36,6 @@ void handle_sigint(int)
int main(int argc, char** argv)
{
if (pledge("stdio", nullptr) < 0) {
perror("pledge");
return 1;
}
int secs;
Core::ArgsParser args_parser;
@ -51,6 +46,12 @@ int main(int argc, char** argv)
memset(&sa, 0, sizeof(struct sigaction));
sa.sa_handler = handle_sigint;
sigaction(SIGINT, &sa, nullptr);
if (pledge("stdio", nullptr) < 0) {
perror("pledge");
return 1;
}
unsigned remaining = sleep(secs);
if (remaining) {
printf("Sleep interrupted with %u seconds remaining.\n", remaining);