Changeset View
Changeset View
Standalone View
Standalone View
main_wayland.cpp
Show First 20 Lines • Show All 57 Lines • ▼ Show 20 Line(s) | |||||
58 | #if HAVE_SYS_PRCTL_H | 58 | #if HAVE_SYS_PRCTL_H | ||
59 | #include <sys/prctl.h> | 59 | #include <sys/prctl.h> | ||
60 | #endif | 60 | #endif | ||
61 | #if HAVE_SYS_PROCCTL_H | 61 | #if HAVE_SYS_PROCCTL_H | ||
62 | #include <unistd.h> | 62 | #include <unistd.h> | ||
63 | #include <sys/procctl.h> | 63 | #include <sys/procctl.h> | ||
64 | #endif | 64 | #endif | ||
65 | 65 | | |||
66 | #if HAVE_LIBCAP | ||||
67 | #include <sys/capability.h> | ||||
68 | #endif | ||||
69 | | ||||
70 | #include <sched.h> | ||||
71 | | ||||
66 | #include <iostream> | 72 | #include <iostream> | ||
67 | #include <iomanip> | 73 | #include <iomanip> | ||
68 | 74 | | |||
69 | namespace KWin | 75 | namespace KWin | ||
70 | { | 76 | { | ||
71 | 77 | | |||
72 | static void sighandler(int) | 78 | static void sighandler(int) | ||
73 | { | 79 | { | ||
▲ Show 20 Lines • Show All 359 Lines • ▼ Show 20 Line(s) | |||||
433 | #if HAVE_PR_SET_DUMPABLE | 439 | #if HAVE_PR_SET_DUMPABLE | ||
434 | prctl(PR_SET_DUMPABLE, 1); | 440 | prctl(PR_SET_DUMPABLE, 1); | ||
435 | #endif | 441 | #endif | ||
436 | signal(sig, SIG_IGN); | 442 | signal(sig, SIG_IGN); | ||
437 | raise(sig); | 443 | raise(sig); | ||
438 | return; | 444 | return; | ||
439 | } | 445 | } | ||
440 | 446 | | |||
447 | void gainRealTime() | ||||
448 | { | ||||
449 | #if HAVE_SCHED_RESET_ON_FORK | ||||
450 | const int minPriority = sched_get_priority_min(SCHED_RR); | ||||
451 | struct sched_param sp; | ||||
452 | sp.sched_priority = minPriority; | ||||
453 | sched_setscheduler(0, SCHED_RR | SCHED_RESET_ON_FORK, &sp); | ||||
454 | #endif | ||||
455 | } | ||||
456 | | ||||
457 | void dropNiceCapability() | ||||
458 | { | ||||
459 | #if HAVE_LIBCAP | ||||
460 | cap_t caps = cap_get_proc(); | ||||
461 | if (!caps) { | ||||
462 | return; | ||||
463 | } | ||||
464 | cap_value_t capList[] = { CAP_SYS_NICE }; | ||||
465 | if (cap_set_flag(caps, CAP_PERMITTED, 1, capList, CAP_CLEAR) == -1) { | ||||
466 | cap_free(caps); | ||||
467 | return; | ||||
468 | } | ||||
469 | if (cap_set_flag(caps, CAP_EFFECTIVE, 1, capList, CAP_CLEAR) == -1) { | ||||
470 | cap_free(caps); | ||||
471 | return; | ||||
472 | } | ||||
473 | cap_set_proc(caps); | ||||
474 | cap_free(caps); | ||||
475 | #endif | ||||
476 | } | ||||
477 | | ||||
441 | } // namespace | 478 | } // namespace | ||
442 | 479 | | |||
443 | int main(int argc, char * argv[]) | 480 | int main(int argc, char * argv[]) | ||
444 | { | 481 | { | ||
445 | KWin::disablePtrace(); | 482 | KWin::disablePtrace(); | ||
446 | KWin::Application::setupMalloc(); | 483 | KWin::Application::setupMalloc(); | ||
447 | KWin::Application::setupLocalizedString(); | 484 | KWin::Application::setupLocalizedString(); | ||
485 | KWin::gainRealTime(); | ||||
486 | KWin::dropNiceCapability(); | ||||
448 | 487 | | |||
449 | if (signal(SIGTERM, KWin::sighandler) == SIG_IGN) | 488 | if (signal(SIGTERM, KWin::sighandler) == SIG_IGN) | ||
450 | signal(SIGTERM, SIG_IGN); | 489 | signal(SIGTERM, SIG_IGN); | ||
451 | if (signal(SIGINT, KWin::sighandler) == SIG_IGN) | 490 | if (signal(SIGINT, KWin::sighandler) == SIG_IGN) | ||
452 | signal(SIGINT, SIG_IGN); | 491 | signal(SIGINT, SIG_IGN); | ||
453 | if (signal(SIGHUP, KWin::sighandler) == SIG_IGN) | 492 | if (signal(SIGHUP, KWin::sighandler) == SIG_IGN) | ||
454 | signal(SIGHUP, SIG_IGN); | 493 | signal(SIGHUP, SIG_IGN); | ||
455 | signal(SIGABRT, KWin::unsetDumpable); | 494 | signal(SIGABRT, KWin::unsetDumpable); | ||
▲ Show 20 Lines • Show All 309 Lines • Show Last 20 Lines |