[LTP] [PATCH v5] kill01: New case cgroup kill
Wei Gao
wegao@suse.com
Sat Mar 18 06:00:41 CET 2023
On Thu, Mar 16, 2023 at 11:10:07AM +0000, Richard Palethorpe wrote:
>
> Wei Gao <wegao@suse.com> writes:
>
> >> > +static int cg_run_nowait(const struct tst_cg_group *const cg,
> >> > + void (*fn)(void))
> >>
> >> Why keep this function?
> >>
> >> If you want to convert tests to LTP, then don't do the minimum possible
> >> to use the LTP API. Use as much of it as possible otherwise we are just
> >> importing brittle self tests.
> >>
> > function is useful and wrap the fork action & put pid into cgroup.procs,
> > is there any LTP API can replace this function? Could you help give
> > example.
>
> IMO you don't need to wrap fork or SAFE_CG_PRINTF, just write it inline.
More logic added into this function in latest patch v6, i prefer keep it currently.
>
> >> > +
> >> > + for (i = 0; i < pid_num; i++)
> >> > + pids[i] = cg_run_nowait(cg_child_test_simple, child_fn);
> >>
> >> If the parent is killed and the children are moved then they will return
> >> and cause a fork bomb.
> > There is no extra fork action in child_fn so all child_fn will
> > reparent and exit.
>
> I don't see how it will exit? It seems like it will just return.
The child_fun will exit if parent id is changed like below
+static void child_fn(void)
+{
+ int ppid = getppid();
+
+ while (getppid() == ppid)
+ usleep(1000);
+
+}
More information about the ltp
mailing list