summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorSergey Bugaev <bugaevc@serenityos.org>2020-05-26 13:52:42 +0300
committerAndreas Kling <kling@serenityos.org>2020-05-26 14:35:10 +0200
commit4139838a936ab6dc9325baa912232432fb66c82d (patch)
treea107e8c221b22cf471285ed461f9b8ac0a57e0c3 /Userland
parentcddaeb43d31304a5cb7ccdf8cf08a2bdbfff84cf (diff)
downloadserenity-4139838a936ab6dc9325baa912232432fb66c82d.zip
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.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/functrace.cpp2
-rw-r--r--Userland/sleep.cpp11
2 files changed, 7 insertions, 6 deletions
diff --git a/Userland/functrace.cpp b/Userland/functrace.cpp
index 3e9d7623c0..a282959a6e 100644
--- a/Userland/functrace.cpp
+++ b/Userland/functrace.cpp
@@ -110,7 +110,7 @@ NonnullOwnPtr<HashMap<void*, X86::Instruction>> instrument_code()
int main(int argc, char** argv)
{
- if (pledge("stdio proc exec rpath", nullptr) < 0) {
+ if (pledge("stdio proc exec rpath sigaction", nullptr) < 0) {
perror("pledge");
return 1;
}
diff --git a/Userland/sleep.cpp b/Userland/sleep.cpp
index 76d7440e21..e0e48612da 100644
--- a/Userland/sleep.cpp
+++ b/Userland/sleep.cpp
@@ -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);