5d64581e10
* desc.c (decode_select): Move assignment out of if() condition. * file.c (sprinttime): Likewise. (sys_getdirentries): Likewise. * io.c (sys_ioctl): Likewise. * strace.c (test_ptrace_setoptions_followfork): Likewise. (main): Likewise. (proc_open): Likewise. (detach): Likewise. (proc_poll): Likewise. (trace): Likewise. * syscall.c (qualify): Likewise. (sys_indir): Likewise. * test/procpollable.c (main): Likewise. * test/sfd.c (main): Likewise. * time.c (printtv_bitness): Likewise. (sprinttv): Likewise. (print_timespec): Likewise. (void sprint_timespec): Likewise. (printitv_bitness): Likewise. * util.c (dumpstr): Likewise. (umovestr): Likewise. (fixvfork): Likewise. Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
45 lines
633 B
C
45 lines
633 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <signal.h>
|
|
#include <sys/procfs.h>
|
|
#include <sys/stropts.h>
|
|
#include <poll.h>
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
int pid;
|
|
char proc[32];
|
|
FILE *pfp;
|
|
struct pollfd pfd;
|
|
|
|
pid = fork();
|
|
if (pid == 0) {
|
|
pause();
|
|
exit(0);
|
|
}
|
|
|
|
sprintf(proc, "/proc/%d", pid);
|
|
|
|
pfp = fopen(proc, "r+");
|
|
if (pfp == NULL)
|
|
goto fail;
|
|
|
|
if (ioctl(fileno(pfp), PIOCSTOP, NULL) < 0)
|
|
goto fail;
|
|
|
|
pfd.fd = fileno(pfp);
|
|
pfd.events = POLLPRI;
|
|
|
|
if (poll(&pfd, 1, 0) < 0)
|
|
goto fail;
|
|
|
|
if (!(pfd.revents & POLLPRI))
|
|
goto fail;
|
|
|
|
kill(pid, SIGKILL);
|
|
exit(0);
|
|
fail:
|
|
kill(pid, SIGKILL);
|
|
exit(1);
|
|
}
|