]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/libsystemd/sd-daemon/sd-daemon.c
libsystemd: use IN_SET macro
[thirdparty/systemd.git] / src / libsystemd / sd-daemon / sd-daemon.c
CommitLineData
abbbea81 1/***
0ebee881
KS
2 This file is part of systemd.
3
abbbea81
LP
4 Copyright 2010 Lennart Poettering
5
0ebee881
KS
6 systemd is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version.
10
11 systemd is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
abbbea81 15
0ebee881
KS
16 You should have received a copy of the GNU Lesser General Public License
17 along with systemd; If not, see <http://www.gnu.org/licenses/>.
18***/
8c47c732 19
abbbea81 20#include <errno.h>
916abb21 21#include <limits.h>
0ebee881 22#include <mqueue.h>
8dd4c05b
LP
23#include <netinet/in.h>
24#include <stdarg.h>
25#include <stddef.h>
26#include <stdio.h>
27#include <stdlib.h>
28#include <string.h>
29#include <sys/socket.h>
30#include <sys/stat.h>
31#include <sys/un.h>
32#include <unistd.h>
abbbea81 33
07630cea
LP
34#include "sd-daemon.h"
35
b5efdb8a 36#include "alloc-util.h"
3ffd4af2 37#include "fd-util.h"
f4f15635 38#include "fs-util.h"
6bedfcbb 39#include "parse-util.h"
be8f4e9e 40#include "path-util.h"
3cb46740 41#include "socket-util.h"
8dd4c05b
LP
42#include "strv.h"
43#include "util.h"
44
a47806fa
LP
45#define SNDBUF_SIZE (8*1024*1024)
46
8dd4c05b
LP
47static void unsetenv_all(bool unset_environment) {
48
49 if (!unset_environment)
50 return;
51
52 unsetenv("LISTEN_PID");
53 unsetenv("LISTEN_FDS");
54 unsetenv("LISTEN_FDNAMES");
55}
56
0ebee881 57_public_ int sd_listen_fds(int unset_environment) {
abbbea81 58 const char *e;
046c93f8 59 int n, r, fd;
be8f4e9e 60 pid_t pid;
abbbea81 61
50425d16
MS
62 e = getenv("LISTEN_PID");
63 if (!e) {
abbbea81
LP
64 r = 0;
65 goto finish;
66 }
67
be8f4e9e
LP
68 r = parse_pid(e, &pid);
69 if (r < 0)
abbbea81 70 goto finish;
abbbea81
LP
71
72 /* Is this for us? */
df0ff127 73 if (getpid_cached() != pid) {
abbbea81
LP
74 r = 0;
75 goto finish;
76 }
77
50425d16
MS
78 e = getenv("LISTEN_FDS");
79 if (!e) {
abbbea81
LP
80 r = 0;
81 goto finish;
82 }
83
046c93f8 84 r = safe_atoi(e, &n);
be8f4e9e 85 if (r < 0)
abbbea81 86 goto finish;
8640e111 87
046c93f8
VC
88 assert_cc(SD_LISTEN_FDS_START < INT_MAX);
89 if (n <= 0 || n > INT_MAX - SD_LISTEN_FDS_START) {
90 r = -EINVAL;
91 goto finish;
92 }
93
94 for (fd = SD_LISTEN_FDS_START; fd < SD_LISTEN_FDS_START + n; fd ++) {
be8f4e9e
LP
95 r = fd_cloexec(fd, true);
96 if (r < 0)
8640e111 97 goto finish;
8640e111
LP
98 }
99
046c93f8 100 r = n;
abbbea81
LP
101
102finish:
8dd4c05b
LP
103 unsetenv_all(unset_environment);
104 return r;
105}
106
107_public_ int sd_listen_fds_with_names(int unset_environment, char ***names) {
108 _cleanup_strv_free_ char **l = NULL;
109 bool have_names;
110 int n_names = 0, n_fds;
111 const char *e;
112 int r;
113
114 if (!names)
115 return sd_listen_fds(unset_environment);
116
117 e = getenv("LISTEN_FDNAMES");
118 if (e) {
119 n_names = strv_split_extract(&l, e, ":", EXTRACT_DONT_COALESCE_SEPARATORS);
120 if (n_names < 0) {
121 unsetenv_all(unset_environment);
122 return n_names;
123 }
124
125 have_names = true;
126 } else
127 have_names = false;
128
129 n_fds = sd_listen_fds(unset_environment);
130 if (n_fds <= 0)
131 return n_fds;
132
133 if (have_names) {
134 if (n_names != n_fds)
135 return -EINVAL;
136 } else {
137 r = strv_extend_n(&l, "unknown", n_fds);
138 if (r < 0)
139 return r;
abbbea81
LP
140 }
141
8dd4c05b
LP
142 *names = l;
143 l = NULL;
144
145 return n_fds;
abbbea81 146}
7c394faa 147
0ebee881 148_public_ int sd_is_fifo(int fd, const char *path) {
7c394faa
LP
149 struct stat st_fd;
150
e6803801 151 assert_return(fd >= 0, -EBADF);
7c394faa 152
7c394faa
LP
153 if (fstat(fd, &st_fd) < 0)
154 return -errno;
155
156 if (!S_ISFIFO(st_fd.st_mode))
157 return 0;
158
159 if (path) {
160 struct stat st_path;
161
fd8bccfb 162 if (stat(path, &st_path) < 0) {
7c394faa 163
945c2931 164 if (IN_SET(errno, ENOENT, ENOTDIR))
7c394faa
LP
165 return 0;
166
167 return -errno;
168 }
169
170 return
171 st_path.st_dev == st_fd.st_dev &&
172 st_path.st_ino == st_fd.st_ino;
173 }
174
175 return 1;
176}
177
0ebee881 178_public_ int sd_is_special(int fd, const char *path) {
4160ec67
WD
179 struct stat st_fd;
180
e6803801 181 assert_return(fd >= 0, -EBADF);
4160ec67
WD
182
183 if (fstat(fd, &st_fd) < 0)
184 return -errno;
185
186 if (!S_ISREG(st_fd.st_mode) && !S_ISCHR(st_fd.st_mode))
187 return 0;
188
189 if (path) {
190 struct stat st_path;
191
192 if (stat(path, &st_path) < 0) {
193
945c2931 194 if (IN_SET(errno, ENOENT, ENOTDIR))
4160ec67
WD
195 return 0;
196
197 return -errno;
198 }
199
200 if (S_ISREG(st_fd.st_mode) && S_ISREG(st_path.st_mode))
201 return
202 st_path.st_dev == st_fd.st_dev &&
203 st_path.st_ino == st_fd.st_ino;
204 else if (S_ISCHR(st_fd.st_mode) && S_ISCHR(st_path.st_mode))
205 return st_path.st_rdev == st_fd.st_rdev;
206 else
207 return 0;
208 }
209
210 return 1;
211}
212
e6a3081a 213static int sd_is_socket_internal(int fd, int type, int listening) {
7c394faa
LP
214 struct stat st_fd;
215
e6803801 216 assert_return(fd >= 0, -EBADF);
be8f4e9e 217 assert_return(type >= 0, -EINVAL);
7c394faa
LP
218
219 if (fstat(fd, &st_fd) < 0)
220 return -errno;
221
222 if (!S_ISSOCK(st_fd.st_mode))
223 return 0;
224
225 if (type != 0) {
226 int other_type = 0;
227 socklen_t l = sizeof(other_type);
228
229 if (getsockopt(fd, SOL_SOCKET, SO_TYPE, &other_type, &l) < 0)
230 return -errno;
231
232 if (l != sizeof(other_type))
233 return -EINVAL;
234
235 if (other_type != type)
236 return 0;
237 }
238
239 if (listening >= 0) {
240 int accepting = 0;
241 socklen_t l = sizeof(accepting);
242
243 if (getsockopt(fd, SOL_SOCKET, SO_ACCEPTCONN, &accepting, &l) < 0)
244 return -errno;
245
246 if (l != sizeof(accepting))
247 return -EINVAL;
248
dde770cf 249 if (!accepting != !listening)
7c394faa
LP
250 return 0;
251 }
252
253 return 1;
254}
255
0ebee881 256_public_ int sd_is_socket(int fd, int family, int type, int listening) {
88ce42f6
LP
257 int r;
258
e6803801 259 assert_return(fd >= 0, -EBADF);
be8f4e9e 260 assert_return(family >= 0, -EINVAL);
88ce42f6 261
50425d16
MS
262 r = sd_is_socket_internal(fd, type, listening);
263 if (r <= 0)
88ce42f6
LP
264 return r;
265
266 if (family > 0) {
1c633045
ZJS
267 union sockaddr_union sockaddr = {};
268 socklen_t l = sizeof(sockaddr);
88ce42f6
LP
269
270 if (getsockname(fd, &sockaddr.sa, &l) < 0)
271 return -errno;
272
b7f42664 273 if (l < sizeof(sa_family_t))
88ce42f6
LP
274 return -EINVAL;
275
276 return sockaddr.sa.sa_family == family;
277 }
278
279 return 1;
280}
281
0ebee881 282_public_ int sd_is_socket_inet(int fd, int family, int type, int listening, uint16_t port) {
1c633045
ZJS
283 union sockaddr_union sockaddr = {};
284 socklen_t l = sizeof(sockaddr);
7c394faa
LP
285 int r;
286
e6803801 287 assert_return(fd >= 0, -EBADF);
be8f4e9e 288 assert_return(IN_SET(family, 0, AF_INET, AF_INET6), -EINVAL);
88ce42f6 289
50425d16
MS
290 r = sd_is_socket_internal(fd, type, listening);
291 if (r <= 0)
7c394faa
LP
292 return r;
293
7c394faa
LP
294 if (getsockname(fd, &sockaddr.sa, &l) < 0)
295 return -errno;
296
b7f42664 297 if (l < sizeof(sa_family_t))
7c394faa
LP
298 return -EINVAL;
299
945c2931 300 if (!IN_SET(sockaddr.sa.sa_family, AF_INET, AF_INET6))
7c394faa
LP
301 return 0;
302
be8f4e9e 303 if (family != 0)
88ce42f6
LP
304 if (sockaddr.sa.sa_family != family)
305 return 0;
306
7c394faa
LP
307 if (port > 0) {
308 if (sockaddr.sa.sa_family == AF_INET) {
309 if (l < sizeof(struct sockaddr_in))
310 return -EINVAL;
311
8e38570e 312 return htobe16(port) == sockaddr.in.sin_port;
7c394faa
LP
313 } else {
314 if (l < sizeof(struct sockaddr_in6))
315 return -EINVAL;
316
8e38570e 317 return htobe16(port) == sockaddr.in6.sin6_port;
7c394faa
LP
318 }
319 }
320
321 return 1;
322}
323
f6f372d2
ZJS
324_public_ int sd_is_socket_sockaddr(int fd, int type, const struct sockaddr* addr, unsigned addr_len, int listening) {
325 union sockaddr_union sockaddr = {};
326 socklen_t l = sizeof(sockaddr);
327 int r;
328
329 assert_return(fd >= 0, -EBADF);
330 assert_return(addr, -EINVAL);
331 assert_return(addr_len >= sizeof(sa_family_t), -ENOBUFS);
332 assert_return(IN_SET(addr->sa_family, AF_INET, AF_INET6), -EPFNOSUPPORT);
333
334 r = sd_is_socket_internal(fd, type, listening);
335 if (r <= 0)
336 return r;
337
338 if (getsockname(fd, &sockaddr.sa, &l) < 0)
339 return -errno;
340
341 if (l < sizeof(sa_family_t))
342 return -EINVAL;
343
344 if (sockaddr.sa.sa_family != addr->sa_family)
345 return 0;
346
347 if (sockaddr.sa.sa_family == AF_INET) {
348 const struct sockaddr_in *in = (const struct sockaddr_in *) addr;
349
350 if (l < sizeof(struct sockaddr_in) || addr_len < sizeof(struct sockaddr_in))
351 return -EINVAL;
352
353 if (in->sin_port != 0 &&
354 sockaddr.in.sin_port != in->sin_port)
355 return false;
356
357 return sockaddr.in.sin_addr.s_addr == in->sin_addr.s_addr;
358
359 } else {
360 const struct sockaddr_in6 *in = (const struct sockaddr_in6 *) addr;
361
362 if (l < sizeof(struct sockaddr_in6) || addr_len < sizeof(struct sockaddr_in6))
363 return -EINVAL;
364
365 if (in->sin6_port != 0 &&
366 sockaddr.in6.sin6_port != in->sin6_port)
367 return false;
368
369 if (in->sin6_flowinfo != 0 &&
370 sockaddr.in6.sin6_flowinfo != in->sin6_flowinfo)
371 return false;
372
373 if (in->sin6_scope_id != 0 &&
374 sockaddr.in6.sin6_scope_id != in->sin6_scope_id)
375 return false;
376
377 return memcmp(sockaddr.in6.sin6_addr.s6_addr, in->sin6_addr.s6_addr,
378 sizeof(in->sin6_addr.s6_addr)) == 0;
379 }
380}
381
0ebee881 382_public_ int sd_is_socket_unix(int fd, int type, int listening, const char *path, size_t length) {
1c633045
ZJS
383 union sockaddr_union sockaddr = {};
384 socklen_t l = sizeof(sockaddr);
7c394faa
LP
385 int r;
386
e6803801 387 assert_return(fd >= 0, -EBADF);
be8f4e9e 388
50425d16
MS
389 r = sd_is_socket_internal(fd, type, listening);
390 if (r <= 0)
7c394faa
LP
391 return r;
392
7c394faa
LP
393 if (getsockname(fd, &sockaddr.sa, &l) < 0)
394 return -errno;
395
b7f42664 396 if (l < sizeof(sa_family_t))
7c394faa
LP
397 return -EINVAL;
398
399 if (sockaddr.sa.sa_family != AF_UNIX)
400 return 0;
401
402 if (path) {
d1d7caee 403 if (length == 0)
7c394faa
LP
404 length = strlen(path);
405
d1d7caee 406 if (length == 0)
7c394faa 407 /* Unnamed socket */
0e098b15 408 return l == offsetof(struct sockaddr_un, sun_path);
7c394faa 409
7c394faa
LP
410 if (path[0])
411 /* Normal path socket */
cd250a39 412 return
0e098b15 413 (l >= offsetof(struct sockaddr_un, sun_path) + length + 1) &&
cd250a39 414 memcmp(path, sockaddr.un.sun_path, length+1) == 0;
7c394faa
LP
415 else
416 /* Abstract namespace socket */
cd250a39 417 return
0e098b15 418 (l == offsetof(struct sockaddr_un, sun_path) + length) &&
cd250a39 419 memcmp(path, sockaddr.un.sun_path, length) == 0;
7c394faa
LP
420 }
421
422 return 1;
423}
8c47c732 424
0ebee881 425_public_ int sd_is_mq(int fd, const char *path) {
916abb21
LP
426 struct mq_attr attr;
427
0260d1d5
ZJS
428 /* Check that the fd is valid */
429 assert_return(fcntl(fd, F_GETFD) >= 0, -errno);
916abb21 430
0260d1d5
ZJS
431 if (mq_getattr(fd, &attr) < 0) {
432 if (errno == EBADF)
433 /* A non-mq fd (or an invalid one, but we ruled that out above) */
434 return 0;
916abb21 435 return -errno;
0260d1d5 436 }
916abb21
LP
437
438 if (path) {
439 char fpath[PATH_MAX];
440 struct stat a, b;
441
be8f4e9e 442 assert_return(path_is_absolute(path), -EINVAL);
916abb21
LP
443
444 if (fstat(fd, &a) < 0)
445 return -errno;
446
447 strncpy(stpcpy(fpath, "/dev/mqueue"), path, sizeof(fpath) - 12);
448 fpath[sizeof(fpath)-1] = 0;
449
450 if (stat(fpath, &b) < 0)
451 return -errno;
452
453 if (a.st_dev != b.st_dev ||
454 a.st_ino != b.st_ino)
455 return 0;
456 }
457
458 return 1;
916abb21
LP
459}
460
a354329f
LP
461_public_ int sd_pid_notify_with_fds(pid_t pid, int unset_environment, const char *state, const int *fds, unsigned n_fds) {
462 union sockaddr_union sockaddr = {
463 .sa.sa_family = AF_UNIX,
464 };
465 struct iovec iovec = {
466 .iov_base = (char*) state,
467 };
468 struct msghdr msghdr = {
469 .msg_iov = &iovec,
470 .msg_iovlen = 1,
471 .msg_name = &sockaddr,
472 };
a354329f
LP
473 _cleanup_close_ int fd = -1;
474 struct cmsghdr *cmsg = NULL;
475 const char *e;
64144440 476 bool have_pid;
be8f4e9e 477 int r;
8c47c732
LP
478
479 if (!state) {
480 r = -EINVAL;
481 goto finish;
482 }
483
a354329f
LP
484 if (n_fds > 0 && !fds) {
485 r = -EINVAL;
486 goto finish;
487 }
488
50425d16
MS
489 e = getenv("NOTIFY_SOCKET");
490 if (!e)
08bfb810 491 return 0;
8c47c732
LP
492
493 /* Must be an abstract socket, or an absolute path */
945c2931 494 if (!IN_SET(e[0], '@', '/') || e[1] == 0) {
8c47c732
LP
495 r = -EINVAL;
496 goto finish;
497 }
498
638b56cd
LP
499 if (strlen(e) > sizeof(sockaddr.un.sun_path)) {
500 r = -EINVAL;
501 goto finish;
502 }
503
50425d16
MS
504 fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0);
505 if (fd < 0) {
8c47c732
LP
506 r = -errno;
507 goto finish;
508 }
509
a47806fa
LP
510 fd_inc_sndbuf(fd, SNDBUF_SIZE);
511
a354329f 512 iovec.iov_len = strlen(state);
8c47c732 513
a354329f 514 strncpy(sockaddr.un.sun_path, e, sizeof(sockaddr.un.sun_path));
8c47c732
LP
515 if (sockaddr.un.sun_path[0] == '@')
516 sockaddr.un.sun_path[0] = 0;
517
fc2fffe7 518 msghdr.msg_namelen = SOCKADDR_UN_LEN(sockaddr.un);
a013bd94 519
df0ff127 520 have_pid = pid != 0 && pid != getpid_cached();
d4a144fa 521
64144440 522 if (n_fds > 0 || have_pid) {
96d49011 523 /* CMSG_SPACE(0) may return value different than zero, which results in miscalculated controllen. */
c463a6f1
LP
524 msghdr.msg_controllen =
525 (n_fds > 0 ? CMSG_SPACE(sizeof(int) * n_fds) : 0) +
526 (have_pid ? CMSG_SPACE(sizeof(struct ucred)) : 0);
527
40f44238 528 msghdr.msg_control = alloca0(msghdr.msg_controllen);
a354329f
LP
529
530 cmsg = CMSG_FIRSTHDR(&msghdr);
64144440
ZJS
531 if (n_fds > 0) {
532 cmsg->cmsg_level = SOL_SOCKET;
533 cmsg->cmsg_type = SCM_RIGHTS;
534 cmsg->cmsg_len = CMSG_LEN(sizeof(int) * n_fds);
a354329f 535
64144440 536 memcpy(CMSG_DATA(cmsg), fds, sizeof(int) * n_fds);
be8f4e9e 537
64144440
ZJS
538 if (have_pid)
539 assert_se(cmsg = CMSG_NXTHDR(&msghdr, cmsg));
540 }
a354329f 541
64144440
ZJS
542 if (have_pid) {
543 struct ucred *ucred;
be8f4e9e 544
64144440
ZJS
545 cmsg->cmsg_level = SOL_SOCKET;
546 cmsg->cmsg_type = SCM_CREDENTIALS;
547 cmsg->cmsg_len = CMSG_LEN(sizeof(struct ucred));
be8f4e9e 548
64144440
ZJS
549 ucred = (struct ucred*) CMSG_DATA(cmsg);
550 ucred->pid = pid;
551 ucred->uid = getuid();
552 ucred->gid = getgid();
553 }
be8f4e9e
LP
554 }
555
556 /* First try with fake ucred data, as requested */
557 if (sendmsg(fd, &msghdr, MSG_NOSIGNAL) >= 0) {
558 r = 1;
8c47c732
LP
559 goto finish;
560 }
561
a354329f 562 /* If that failed, try with our own ucred instead */
64144440
ZJS
563 if (have_pid) {
564 msghdr.msg_controllen -= CMSG_SPACE(sizeof(struct ucred));
565 if (msghdr.msg_controllen == 0)
a354329f 566 msghdr.msg_control = NULL;
be8f4e9e
LP
567
568 if (sendmsg(fd, &msghdr, MSG_NOSIGNAL) >= 0) {
569 r = 1;
570 goto finish;
571 }
572 }
573
574 r = -errno;
8c47c732
LP
575
576finish:
577 if (unset_environment)
578 unsetenv("NOTIFY_SOCKET");
579
8c47c732 580 return r;
8c47c732
LP
581}
582
a354329f
LP
583_public_ int sd_pid_notify(pid_t pid, int unset_environment, const char *state) {
584 return sd_pid_notify_with_fds(pid, unset_environment, state, NULL, 0);
585}
586
be8f4e9e 587_public_ int sd_notify(int unset_environment, const char *state) {
a354329f 588 return sd_pid_notify_with_fds(0, unset_environment, state, NULL, 0);
be8f4e9e
LP
589}
590
591_public_ int sd_pid_notifyf(pid_t pid, int unset_environment, const char *format, ...) {
592 _cleanup_free_ char *p = NULL;
593 int r;
594
595 if (format) {
596 va_list ap;
597
598 va_start(ap, format);
599 r = vasprintf(&p, format, ap);
600 va_end(ap);
601
602 if (r < 0 || !p)
603 return -ENOMEM;
604 }
605
606 return sd_pid_notify(pid, unset_environment, p);
607}
608
0ebee881 609_public_ int sd_notifyf(int unset_environment, const char *format, ...) {
be8f4e9e 610 _cleanup_free_ char *p = NULL;
8c47c732
LP
611 int r;
612
be8f4e9e
LP
613 if (format) {
614 va_list ap;
8c47c732 615
be8f4e9e
LP
616 va_start(ap, format);
617 r = vasprintf(&p, format, ap);
618 va_end(ap);
8c47c732 619
be8f4e9e
LP
620 if (r < 0 || !p)
621 return -ENOMEM;
622 }
8c47c732 623
be8f4e9e 624 return sd_pid_notify(0, unset_environment, p);
8c47c732 625}
40473a70 626
0ebee881 627_public_ int sd_booted(void) {
66e41181
LP
628 /* We test whether the runtime unit file directory has been
629 * created. This takes place in mount-setup.c, so is
630 * guaranteed to happen very early during boot. */
40473a70 631
31021ba0 632 return laccess("/run/systemd/system/", F_OK) >= 0;
40473a70 633}
09812eb7 634
0ebee881 635_public_ int sd_watchdog_enabled(int unset_environment, uint64_t *usec) {
a9becdd6 636 const char *s, *p = ""; /* p is set to dummy value to do unsetting */
be8f4e9e 637 uint64_t u;
a9becdd6 638 int r = 0;
09812eb7 639
a9becdd6
ZJS
640 s = getenv("WATCHDOG_USEC");
641 if (!s)
09812eb7 642 goto finish;
09812eb7 643
a9becdd6 644 r = safe_atou64(s, &u);
be8f4e9e 645 if (r < 0)
09812eb7 646 goto finish;
caffe412 647 if (u <= 0 || u >= USEC_INFINITY) {
09812eb7
LP
648 r = -EINVAL;
649 goto finish;
650 }
651
a9becdd6
ZJS
652 p = getenv("WATCHDOG_PID");
653 if (p) {
654 pid_t pid;
655
656 r = parse_pid(p, &pid);
657 if (r < 0)
658 goto finish;
659
660 /* Is this for us? */
df0ff127 661 if (getpid_cached() != pid) {
a9becdd6
ZJS
662 r = 0;
663 goto finish;
664 }
09812eb7
LP
665 }
666
667 if (usec)
be8f4e9e 668 *usec = u;
09812eb7
LP
669
670 r = 1;
671
672finish:
a9becdd6 673 if (unset_environment && s)
09812eb7 674 unsetenv("WATCHDOG_USEC");
a9becdd6
ZJS
675 if (unset_environment && p)
676 unsetenv("WATCHDOG_PID");
09812eb7
LP
677
678 return r;
09812eb7 679}