Re: [PATCH v10 2/2] selftests: add tests for clone3() with *set_tid
From: Adrian Reber
Date: Fri Nov 15 2019 - 10:14:33 EST
On Thu, Nov 14, 2019 at 10:34:21AM -0800, Andrei Vagin wrote:
> > + /*
> > + * This should work and from the parent we should see
> > + * something like 'NSpid: pid 42 1'.
> > + */
> > + test_clone3_set_tid(set_tid, 3, CLONE_NEWPID, 0, 42, true);
> > +
> > + _exit(ksft_cnt.ksft_pass);
> > + }
> > +
> > + close(pipe_1[1]);
> > + close(pipe_2[0]);
> > + while (read(pipe_1[0], &buf, 1) > 0) {
>
> If a child process will crash, this will be a busyloop.
No. To be honest the whole loop is unnecessary. If the loop is entered
there is immediately a break.
> > + ksft_print_msg("[%d] Child is ready and waiting\n", getpid());
> > + break;
> > + }
If the loop is not entered it does not loop. So the whole thing is
useless. I think I was expecting it to block, but it doesn't work that
way.
> > + snprintf(proc_path, sizeof(proc_path), "/proc/%d/status", pid);
> > + f = fopen(proc_path, "r");
> > + if (f == NULL)
> > + ksft_exit_fail_msg(
> > + "%s - Could not open %s\n",
> > + strerror(errno), proc_path);
If the child does not exist anymore, the test will fail here and exit.
Besides this while() I tried to address all your comments in v11. Any
further comments on the test?
Adrian