[LTP] [PATCH 1/3] getpgid01.c: Rewrite using new LTP API

Avinesh Kumar akumar@suse.de
Wed Apr 12 10:52:44 CEST 2023


Hi Cyril,
Thank you for the review.

On Wednesday, April 5, 2023 4:25:29 PM IST you wrote:
> Hi!
> > +	pid_1 = SAFE_FORK();
> > +	if (!pid_1) {
> > +		child_pid = getpid();
> > +		ppid = getppid();
> >  
> > -		if ((pgid_0 = FORK_OR_VFORK()) == -1)
> > -			tst_brkm(TBROK, cleanup, "fork failed");
> > -		if (pgid_0 > 0) {
> > -			while ((pgid_0 = wait(&ex_stat)) != -1) ;
> > +		tst_res(TINFO, "getpid() in child = %d", child_pid);
> > +		tst_res(TINFO, "getppid() in child = %d", ppid);
> > +		tst_res(TINFO, "Running getpgid() in child");
> >  
> > -			if (WEXITSTATUS(ex_stat) == 0)
> > -				tst_resm(TPASS, "%s PASSED", TCID);
> > -			else
> > -				tst_resm(TFAIL, "%s FAILED", TCID);
> > +		TST_EXP_POSITIVE(getpgid(0));
> > +		TST_EXP_EQ_LI(TST_RET, ppid);
> 
> I do not think that this is correct, the previous code compared the
> return value from getpgid(0) against the rest, not parent pid.
I think I wrongly assumed the ppid to be pgid of itself and children processes.
Thanks for pointing it point.
> 
> I guess that the best solution here would be to call getgid() in the
I guess you meant getpgid() here?
> parent and save that to a variable and use that for the comparsion in
> the child.
> 
> 

Regards,
Avinesh





More information about the ltp mailing list