-
Notifications
You must be signed in to change notification settings - Fork 11
/
oldprocs.cc
813 lines (752 loc) · 22.9 KB
/
oldprocs.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
// oldprocs - list/restart processes/services whose executable/shared libraries
// have changed
//
// 2018, Georg Sauthoff <[email protected]>
//
// SPDX-License-Identifier: GPL-3.0-or-later
#include <ixxx/util.hh>
#include <ixxx/posix.hh>
#include <ixxx/ansi.hh>
#include <ixxx/sys_error.hh>
#include <algorithm>
#include <array>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <deque>
#include <utility>
#include <stdexcept>
#include <memory>
#include <assert.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
using namespace std;
struct Args {
bool verbose{false};
bool restart{false};
bool print_pid{false};
bool check_dm{true};
set<string> display_managers;
void parse(int argc, char **argv);
void help(ostream &o, const char *argv0);
};
void Args::parse(int argc, char **argv)
{
for (int i = 1; i < argc; ++i) {
if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) {
help(cout, argv[0]);
exit(0);
} else if (!strcmp(argv[i], "-p") || !strcmp(argv[i], "--pid")) {
print_pid = true;
} else if (!strcmp(argv[i], "-r") || !strcmp(argv[i], "--restart")) {
restart = true;
} else if (!strcmp(argv[i], "-v") || !strcmp(argv[i], "--verbose")) {
verbose = true;
} else if (!strcmp(argv[i], "--no-check-dm")) {
check_dm = false;
} else {
cerr << "Unknown argument: " << argv[1] << '\n';
help(cerr, argv[0]);
exit(1);
}
}
}
void Args::help(ostream &o, const char *argv0)
{
o << "Usage: " << argv0 << " [--restart]\n\n"
"oldprocs - list and/or restart processes whose executable/libraries"
" were updated\n\n";
o << "optional arguments:\n"
" -h, --help show this help message and exit\n"
" --no-check-dm don't care whether a service like gdm/sddm\n"
" has active session (those sessions are terminated\n"
" during a service restart)\n"
" --pid, -p print pids\n"
" --restart, -r automatically restart systemd services\n"
" --verbose, -v print debug output\n"
"\n"
"GPL-3.0-or-later, 2018, Georg Sauthoff\n"
"https://github.com/gsauthof/utility\n\n"
;
}
static bool log_debug;
static void debugP()
{
}
template<typename Arg, typename... Args>
static void debugP(Arg&& arg, Args&&... args)
{
cout << std::forward<Arg>(arg);
debugP(std::forward<Args>(args)...);
}
template<typename... Args>
static void debug(Args&&... args)
{
if (log_debug) {
cout << "[dbg] ";
debugP(std::forward<Args>(args)...);
cout << '\n';
cout.flush();
}
}
static bool is_num(const char *s)
{
for (const char *x = s; *x; ++x)
if (*x < '0' || *x > '9')
return false;
return true;
}
static time_t link_ctime(const std::string &name)
{
struct stat st;
ixxx::posix::lstat(name, &st);
return st.st_ctime;
}
#if 0
static pair<time_t, uid_t> link_ctime_uid(const std::string &name)
{
struct stat st;
ixxx::posix::lstat(name, &st);
return make_pair(st.st_ctime, st.st_uid);
}
#endif
static time_t file_ctime(const char *name)
{
struct stat st;
ixxx::posix::stat(name, &st);
return st.st_ctime;
}
static uid_t file_uid(const std::string &name)
{
struct stat st;
ixxx::posix::stat(name, &st);
return st.st_uid;
}
class Maps_Reader {
public:
Maps_Reader(const string &filename, const char *exe);
~Maps_Reader();
Maps_Reader(const Maps_Reader&) =delete;
Maps_Reader &operator=(const Maps_Reader&) =delete;
const char *next();
private:
ixxx::util::File f_;
char *line_;
size_t n_;
const char *exe_;
};
Maps_Reader::Maps_Reader(const string &filename, const char *exe)
:
f_(filename, "r"),
line_(static_cast<char*>(ixxx::ansi::malloc(1024))),
n_(1024),
exe_(exe)
{
}
Maps_Reader::~Maps_Reader()
{
free(line_);
}
const char *Maps_Reader::next()
{
for (;;) {
auto r = ixxx::posix::getline(&line_, &n_, f_);
if (r == -1)
return nullptr;
char *p = static_cast<char*>(memchr(line_, '\n', r));
if (!p)
return nullptr;
*p = 0;
--r;
const char xmark[] = " r-xp ";
char *e = static_cast<char*>(memmem(line_, r, xmark, sizeof xmark - 1));
if (!e)
continue;
p = static_cast<char*>(memchr(line_, '/', r));
if (!p)
continue;
if (!strcmp(p, exe_))
continue;
*e = 0;
return line_;
}
}
static bool is_deleted(const char *s, size_t l)
{
const char del_mark[] = " (deleted)";
if (l >= sizeof del_mark - 1) {
if (!memcmp(s + (l - (sizeof del_mark - 1)), del_mark, sizeof del_mark - 1))
return true;
}
return false;
}
class Proc_Reader {
public:
Proc_Reader();
enum State { DONE, OK, EXE_DELETED, LIB_DELETED,
EXE_CTIME_MISMATCH, LIB_CTIME_MISMATCH };
State next();
pid_t pid() const;
const char *pid_c_str() const;
const char *exe() const;
uid_t uid() const;
private:
//State state_ {OK};
ixxx::util::Directory proc;
const struct dirent *d{nullptr};
size_t root_off {0};
array<char, 4096> a;
array<char, 4096> b;
string path;
string path2;
mutable uid_t uid_{0};
};
Proc_Reader::Proc_Reader()
:
proc("/proc"),
path("/proc/"),
path2("/proc/")
{
}
uid_t Proc_Reader::uid() const
{
if (!uid_) {
auto l = path.rfind('/');
auto p(path.substr(0, l));
uid_ = file_uid(p);
}
return uid_;
}
pid_t Proc_Reader::pid() const
{
return atol(d->d_name);
}
const char *Proc_Reader::pid_c_str() const
{
return d->d_name;
}
const char *Proc_Reader::exe() const
{
return a.data() + root_off;
}
Proc_Reader::State Proc_Reader::next()
{
for (;;) {
d = proc.read();
if (!d)
return DONE;
if (!is_num(d->d_name))
continue;
try {
for (unsigned k = 0; k<2; ++k) {
try {
path.resize(6);
path += d->d_name;
size_t path_len = path.size();
path += "/root";
auto l = ixxx::posix::readlink(path, b);
path.resize(path_len);
root_off = 0;
if (!k && !is_deleted(b.data(), l)) {
auto p = static_cast<const char*>(
mempcpy(mempcpy(a.data(), path.data(), path.size()), "/root/", 6));
root_off = p - a.data();
}
path += "/exe";
l = root_off + ixxx::posix::readlink(path.data(),
a.data() + root_off, a.size() - root_off - 1);
a[l] = 0;
if (is_deleted(a.data(), l)) {
debug("executable is deleted: ", path, " -> ", a.data());
return EXE_DELETED;
}
// the uid of the /exe might be != than the actual uid
auto x = link_ctime(path);
uid_ = 0;
auto y = file_ctime(a.data());
if (x < y) {
debug("executable updated after process start: ", path, " -> ", a.data());
return EXE_CTIME_MISMATCH;
}
path.resize(path_len);
path += "/maps";
path2.resize(6);
path2 += d->d_name;
path2 += "/map_files/";
size_t path2_len = path2.size();
memcpy(b.data(), a.data(), root_off);
Maps_Reader maps(path, a.data());
while (auto m = maps.next()) {
path2.resize(path2_len);
path2 += m;
l = root_off + ixxx::posix::readlink(path2.data(),
b.data() + root_off, b.size() - root_off - 1);
b[l] = 0;
if (is_deleted(b.data(), l)) {
debug("library deleted: ", path, ' ', b.data());
return LIB_DELETED;
}
auto x = link_ctime(path2);
auto y = file_ctime(b.data());
if (x < y) {
debug("library updated after process start: ", path, ' ', b.data());
return LIB_CTIME_MISMATCH;
}
}
break;
} catch (const ixxx::stat_error &e) {
if (e.code() == ENOENT) {
debug("could not stat while processing: ", path);
continue;
}
}
}
} catch (const ixxx::readlink_error &e) {
if (e.code() == EACCES)
continue;
}
return OK;
}
}
enum class Service {
UNKNOWN,
SYSTEMD,
YES
};
#if 0
static ostream &operator<<(ostream &o, Service s)
{
switch (s) {
case Service::UNKNOWN: o << "UNKNOWN"; break;
case Service::SYSTEMD: o << "SYSTEMD"; break;
case Service::YES: o << "YES"; break;
case Service::SESSION: o << "SESSION"; break;
}
return o;
}
#endif
static bool starts_with(const char *begin, const char *end,
const char *b, const char *e)
{
size_t n = end-begin;
size_t m = e-b;
if (m > n)
return false;
return equal(begin, begin+m, b);
}
static bool ends_with(const char *begin, const char *end,
const char *b, const char *e)
{
size_t n = end-begin;
size_t m = e-b;
if (m > n)
return false;
return equal(end - m, end, b);
}
static pair<Service, string> get_service(const char *pid_str)
{
string filename("/proc/");
filename += pid_str;
filename += "/cgroup";
ixxx::util::FD fd(filename, O_RDONLY);
array<char, 8*1024> a;
size_t n = ixxx::util::read_all(fd, a);
const char *begin = a.data();
const char *end = begin + n;
const char name_mark[] = "/system.slice/";
const char *p = search(begin, end, name_mark, name_mark + sizeof name_mark - 1);
if (p == end || (p > begin && *(p-1) != '\n' ) ) {
p = begin;
} else {
p += sizeof name_mark - 1;
}
end = find(p, end, '\n');
const char service_mark[] = ".service";
if (ends_with(p, end, service_mark, service_mark + sizeof service_mark - 1)) {
p = static_cast<const char*>(memrchr(p-1, '/', end-(p-1)));
return make_pair(Service::YES, string(p+1, end));
}
const char init_mark[] = "/init.scope";
if (ends_with(p-1, end, init_mark, init_mark + sizeof init_mark - 1)) {
return make_pair(Service::SYSTEMD, string());
}
return make_pair(Service::UNKNOWN, string());
}
extern char **environ;
static void execute(const vector<const char *> &args)
{
assert(args.size() > 1);
assert(args.back() == nullptr);
cout << " => Executing:";
auto i = args.begin();
auto e = args.end() - 1;
for (; i != e; ++i) {
cout << ' ' << *i;
}
cout << '\n';
pid_t child_pid = 0;
ixxx::posix::spawnp(&child_pid,
args.front(),
nullptr, nullptr,
const_cast<char* const*>(args.data()), environ);
siginfo_t info;
ixxx::posix::waitid(P_PID, child_pid, &info, WEXITED);
if (info.si_code == CLD_EXITED) {
if (info.si_status)
throw runtime_error("command exited with non-zero exit status");
} else {
throw runtime_error("command terminated by a signal");
}
}
class Proc_Checker {
public:
Proc_Checker(const Args &args);
int check();
void report();
private:
void report_system();
void report_users();
const Args *args_{nullptr};
uid_t my_uid {0};
vector<const char *> cmd;
set<string> services;
map<uid_t, set<string>> user_services;
bool auditd {false};
bool systemd {false};
pid_t systemd_pid {0};
bool dbusd {false};
map<uid_t, pid_t> user_systemd;
set<uid_t> user_dbusd;
map<uid_t, map<string, deque<pid_t>>> processes;
};
Proc_Checker::Proc_Checker(const Args &args)
:
args_(&args)
{
my_uid = getuid();
}
int Proc_Checker::check()
{
Proc_Reader reader;
Proc_Reader::State state;
while ((state = reader.next()) != Proc_Reader::DONE) {
if (state == Proc_Reader::OK)
continue;
//cout << reader.pid() << ": " << reader.exe() << " -> restart!\n";
auto x = get_service(reader.pid_c_str());
//cout << " => " << x.first << ' ' << x.second << '\n';
switch (x.first) {
case Service::YES:
if (x.second == "auditd.service")
auditd = true;
else if (x.second == "dbus.service") {
if (reader.uid() < 1000)
dbusd = true;
else {
const char *b = reader.exe();
const char *e = b + strlen(b);
const char dbus_mark[] = "/dbus-daemon";
if (ends_with(b, e, dbus_mark, dbus_mark + sizeof dbus_mark - 1))
user_dbusd.insert(reader.uid());
else {
processes[reader.uid()][reader.exe()].push_back(reader.pid());
}
}
} else {
if (reader.uid() < 1000) {
services.insert(x.second);
} else {
user_services[reader.uid()].insert(x.second);
if (x.second == "gnome-terminal-server.service")
processes[reader.uid()][reader.exe()].push_back(reader.pid());
}
}
break;
case Service::SYSTEMD:
if (reader.uid() < 1000) {
systemd = true;
systemd_pid = reader.pid();
} else {
user_systemd.emplace(reader.uid(), reader.pid());
}
break;
case Service::UNKNOWN:
processes[reader.uid()][reader.exe()].push_back(reader.pid());
break;
default:
;
}
}
if (dbusd)
return 10;
if (!user_dbusd.empty() || !processes.empty())
return 11;
if (!services.empty() || !user_services.empty() || auditd
|| systemd || !user_systemd.empty())
return 15;
return 0;
}
void Proc_Checker::report()
{
report_system();
report_users();
}
void Proc_Checker::report_system()
{
if (dbusd) {
// cf. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=805449
cout << "\nYou have to restart the system (because dbus changed).\n\n";
}
if (auditd || systemd || !services.empty()) {
cout << "\nYou have to restart the following system services:\n\n";
}
if (auditd) {
// cf. https://bugzilla.redhat.com/show_bug.cgi?id=973697
// https://bugzilla.redhat.com/show_bug.cgi?id=1026648
cout << "/usr/libexec/initscripts/legacy-actions/auditd/restart\n";
if (args_->restart && my_uid == 0) {
cmd.clear();
cmd.push_back("/usr/libexec/initscripts/legacy-actions/auditd/restart");
cmd.push_back(nullptr);
execute(cmd);
}
}
if (systemd) {
cout << "systemctl daemon-reexec";
if (args_->print_pid)
cout << " # " << systemd_pid;
cout << '\n';
if (args_->restart && my_uid == 0) {
cmd.clear();
cmd.push_back("systemctl");
cmd.push_back("daemon-reexec");
cmd.push_back(nullptr);
execute(cmd);
}
}
cmd.clear();
cmd.push_back("systemctl");
cmd.push_back("restart");
if (!services.empty()) {
for (auto &service: services) {
cout << "systemctl restart " << service;
if (args_->display_managers.count(service))
cout << " # ATTENTION: a local user session might be terminated";
cout << '\n';
if (args_->restart && my_uid == 0) {
if (args_->display_managers.count(service)) {
cout << " => NOT restarting it automatically!\n";
} else {
cmd.resize(2);
cmd.push_back(service.c_str());
cmd.push_back(nullptr);
execute(cmd);
}
}
}
}
}
void Proc_Checker::report_users()
{
for (auto uid : user_dbusd) {
cout << "\nYou have to logoff/login from/to session of user " << uid;
if (uid == my_uid)
cout << " (your user!)";
cout << "\nbecause dbus changed.\n\n";
}
if (!user_services.empty() || !user_systemd.empty()) {
cout << "\nYou have to restart the following user services:\n\n";
}
if (!user_services.empty()) {
cmd.clear();
cmd.push_back("systemctl");
cmd.push_back("--user");
cmd.push_back("restart");
for (auto &x: user_services) {
for (auto &service: x.second) {
if (x.first != my_uid)
cout << "sudo -u '#" << x.first << "' ";
cout << "systemctl --user restart " << service << '\n';
if (args_->restart && my_uid == x.first) {
cmd.resize(3);
cmd.push_back(service.c_str());
cmd.push_back(nullptr);
execute(cmd);
}
}
}
}
for (auto &x : user_systemd) {
auto &uid = x.first; auto &pid = x.second;
if (uid != my_uid)
cout << "sudo -u '#" << uid << "' ";
cout << "systemctl --user daemon-reexec";
if (args_->print_pid)
cout << " # " << pid;
cout << '\n';
if (args_->restart && my_uid == uid) {
cmd.resize(2);
cmd.push_back("daemon-reexec");
cmd.push_back(nullptr);
execute(cmd);
}
}
if (!processes.empty()) {
cout << "\nThe following user processes must be restarted manually\n(or a session logoff/login might take care of them):\n\n";
for (auto &x : processes) {
for (auto &y : x.second) {
cout << y.first << " (uid " << x.first << ") - pids:";
for (auto pid : y.second) {
cout << ' ' << pid;
}
cout << '\n';
}
}
}
}
static void check_output(const vector<const char*> &args, vector<char> &buf)
{
assert(args.size() > 1);
assert(args.back() == nullptr);
int pipefd[2];
ixxx::posix::pipe(pipefd);
posix_spawn_file_actions_t as;
ixxx::posix::spawn_file_actions_init(&as);
unique_ptr<posix_spawn_file_actions_t,
void(*)(posix_spawn_file_actions_t *)> asp(&as,
ixxx::posix::spawn_file_actions_destroy);
ixxx::posix::spawn_file_actions_addclose(&as, 0);
ixxx::posix::spawn_file_actions_addclose(&as, pipefd[0]);
ixxx::posix::spawn_file_actions_adddup2(&as, pipefd[1], 1);
pid_t child_pid = 0;
ixxx::posix::spawnp(&child_pid,
args.front(),
&as, nullptr,
const_cast<char* const*>(args.data()), environ);
ixxx::posix::close(pipefd[1]);
size_t n = 8*1024;
size_t old_n = n;
while (n == old_n) {
size_t off = buf.size();
buf.resize(off + old_n);
n = ixxx::util::read_all(pipefd[0], buf.data() + off, old_n);
buf.resize(off + n);
}
ixxx::posix::close(pipefd[0]);
siginfo_t info;
ixxx::posix::waitid(P_PID, child_pid, &info, WEXITED);
if (info.si_code == CLD_EXITED) {
if (info.si_status)
throw runtime_error("command exited with non-zero exit status");
} else {
throw runtime_error("command terminated by a signal");
}
}
static deque<string> get_path()
{
deque<string> v;
const char *path = ::getenv("PATH");
const char *i = path;
if (!i)
return v;
const char *end = i + strlen(path);
const char *delim = find(i, end, ':');
while (delim < end) {
v.emplace_back(i, delim);
i = delim + 1;
delim = find(i, end, ':');
}
v.emplace_back(i, end);
for (auto &x : v) {
if (x.empty())
x = ".";
}
return v;
}
static bool have_loginctl()
{
try {
ixxx::util::which(get_path(), "loginctl");
} catch (range_error&) {
return false;
}
return true;
}
static set<string> get_display_managers()
{
set<string> services;
if (!have_loginctl())
return services;
vector<const char *> cmd = { "loginctl", "list-sessions", "--no-legend", nullptr };
vector<char> buf;
check_output(cmd, buf);
deque<string> ids;
{
const char *line = buf.data();
const char *end = buf.data() + buf.size();
const char *line_end = find(line, end, '\n');
while (line_end < buf.data() + buf.size() ) {
const char *x = find_if(line, line_end, [](char c) { return c != ' '; });
const char *y = find(x, line_end, ' ');
ids.emplace_back(x, y);
line = line_end+1;
line_end = find(line, end, '\n');
}
}
cmd.resize(1);
cmd.push_back("show-session");
for (auto &id : ids) {
cmd.push_back(id.c_str());
}
cmd.push_back(nullptr);
check_output(cmd, buf);
{
const char *line = buf.data();
const char *end = buf.data() + buf.size();
const char *line_end = find(line, end, '\n');
//const char type_mark[] = "Type=";
const char service_mark[] = "Service=";
const char sshd_mark[] = "=sshd";
const char gdm_mark[] = "gdm";
while (line_end < buf.data() + buf.size() ) {
if (starts_with(line, line_end,
service_mark, service_mark + sizeof service_mark - 1)
&& !ends_with(line, line_end, sshd_mark,
sshd_mark + sizeof sshd_mark - 1)) {
if (starts_with(line + sizeof service_mark - 1, line_end,
gdm_mark, gdm_mark + sizeof gdm_mark - 1))
services.emplace("gdm");
else
services.emplace(line + sizeof service_mark - 1, line_end);
}
line = line_end+1;
line_end = find(line, end, '\n');
}
}
return services;
}
// rc: 10 => reboot necessary
// rc: 11 => session logout/login necessary
// rc: 15 => auto-restart possible
int main(int argc, char **argv)
{
Args args;
args.parse(argc, argv);
if (args.check_dm)
args.display_managers = get_display_managers();
if (args.verbose)
log_debug = true;;
Proc_Checker pc(args);
int rc = pc.check();
pc.report();
if (rc == 15 && args.restart) {
pc = Proc_Checker(args);
rc = pc.check();
}
return rc;
}