staticint pidfd_metadata_fd(pid_t pid, int pidfd)
{ int procfd, ret; char path[100];
snprintf(path, sizeof(path), "/proc/%d", pid);
procfd = open(path, O_DIRECTORY | O_RDONLY | O_CLOEXEC); if (procfd < 0) {
warn("Failed to open %s\n", path); return -1;
}
/* * Verify that the pid has not been recycled and our /proc/<pid> handle * is still valid.
*/
ret = sys_pidfd_send_signal(pidfd, 0, NULL, 0); if (ret < 0) { switch (errno) { case EPERM: /* Process exists, just not allowed to signal it. */ break; default:
warn("Failed to signal process\n");
close(procfd);
procfd = -1;
}
}
return procfd;
}
int main(int argc, char *argv[])
{ int pidfd = -1, ret = EXIT_FAILURE; char buf[4096] = { 0 };
pid_t pid; int procfd, statusfd;
ssize_t bytes;
pid = pidfd_clone(CLONE_PIDFD, &pidfd); if (pid < 0)
err(ret, "CLONE_PIDFD"); if (pidfd == -1) {
warnx("CLONE_PIDFD is not supported by the kernel"); goto out;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.