public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/2] setpgid/setpgid01.c: cleanup
@ 2014-05-12  6:09 Xiaoguang Wang
  2014-05-12  6:09 ` [LTP] [PATCH 2/2] setpgid/setpgid01.c: add pid = 0 and pgid = 0 test Xiaoguang Wang
  2014-05-14 10:05 ` [LTP] [PATCH 1/2] setpgid/setpgid01.c: cleanup Jan Stancek
  0 siblings, 2 replies; 5+ messages in thread
From: Xiaoguang Wang @ 2014-05-12  6:09 UTC (permalink / raw)
  To: ltp-list

Delete some useless comments.
Do some code re-arrangement.
Some cleanup.

Signed-off-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
---
 testcases/kernel/syscalls/setpgid/setpgid01.c | 204 +++++++-------------------
 1 file changed, 57 insertions(+), 147 deletions(-)

diff --git a/testcases/kernel/syscalls/setpgid/setpgid01.c b/testcases/kernel/syscalls/setpgid/setpgid01.c
index 57e71fc..d35f201 100644
--- a/testcases/kernel/syscalls/setpgid/setpgid01.c
+++ b/testcases/kernel/syscalls/setpgid/setpgid01.c
@@ -31,83 +31,12 @@
  *
  */
 /* $Id: setpgid01.c,v 1.7 2009/11/02 13:57:18 subrata_modak Exp $ */
-/**********************************************************
- *
- *    OS Test - Silicon Graphics, Inc.
- *
- *    TEST IDENTIFIER	: setpgid01
- *
- *    EXECUTED BY	: anyone
- *
- *    TEST TITLE	: Basic test for setpgid(2)
- *
- *    PARENT DOCUMENT	: usctpl01
- *
- *    TEST CASE TOTAL	: 1
- *
- *    WALL CLOCK TIME	: 1
- *
- *    CPU TYPES		: ALL
- *
- *    AUTHOR		: William Roske
- *
- *    CO-PILOT		: Dave Fenner
- *
- *    DATE STARTED	: 03/30/92
- *
- *    INITIAL RELEASE	: UNICOS 7.0
- *
- *    TEST CASES
- *
- * 	1.) setpgid(2) returns...(See Description)
- *
- *    INPUT SPECIFICATIONS
- * 	The standard options for system call tests are accepted.
- *	(See the parse_opts(3) man page).
- *
- *    OUTPUT SPECIFICATIONS
- *$
- *    DURATION
- * 	Terminates - with frequency and infinite modes.
- *
- *    SIGNALS
- * 	Uses SIGUSR1 to pause before test if option set.
- * 	(See the parse_opts(3) man page).
- *
- *    RESOURCES
- * 	None
- *
- *    ENVIRONMENTAL NEEDS
- *      No run-time environmental needs.
- *
- *    SPECIAL PROCEDURAL REQUIREMENTS
- * 	None
- *
- *    INTERCASE DEPENDENCIES
- * 	None
- *
- *    DETAILED DESCRIPTION
- *	This is a Phase I test for the setpgid(2) system call.  It is intended
- *	to provide a limited exposure of the system call, for now.  It
- *	should/will be extended when full functional tests are written for
- *	setpgid(2).
- *
- * 	Setup:
- * 	  Setup signal handling.
- *	  Pause for SIGUSR1 if option specified.
- *
- * 	Test:
- *	 Loop if the proper options are given.
- * 	  Execute system call
- *	  Check return code, if system call failed (return=-1)
- *		Log the errno and Issue a FAIL message.
- *	  Otherwise, Issue a PASS message.
- *
- * 	Cleanup:
- * 	  Print errno log and/or timing stats if options given
- *
- *
- *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
+
+/*
+ * Description:
+ * Verify that:
+ *   1. Basic functionality test for setpgid(2).
+ */
 
 #include <errno.h>
 #include <string.h>
@@ -117,115 +46,96 @@
 #include "test.h"
 #include "usctest.h"
 
-void setup();
-void cleanup();
+static void setup(void);
+static void cleanup(void);
 
 char *TCID = "setpgid01";
-int TST_TOTAL = 1;
-
-int exp_enos[] = { 0, 0 };
 
-int pgid, pid;
+static void setpgid_test1(void);
+static void (*testfunc[])(void) = { setpgid_test1};
+int TST_TOTAL = ARRAY_SIZE(testfunc);
 
 int main(int ac, char **av)
 {
-	int lc;
+	int i, lc;
 	char *msg;
 
-    /***************************************************************
-     * parse standard options
-     ***************************************************************/
 	if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL)
 		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
 
-    /***************************************************************
-     * perform global setup for test
-     ***************************************************************/
 	setup();
 
-	/* set the expected errnos... */
-	TEST_EXP_ENOS(exp_enos);
-
-    /***************************************************************
-     * check looping state if -c option given
-     ***************************************************************/
 	for (lc = 0; TEST_LOOPING(lc); lc++) {
-
 		tst_count = 0;
 
-		/*
-		 * Call setpgid(2)
-		 */
-		TEST(setpgid(pid, pgid));
-
-		/* check return code */
-		if (TEST_RETURN == -1) {
-			TEST_ERROR_LOG(TEST_ERRNO);
-			tst_resm(TFAIL, "setpgid(%d, %d) Failed, errno=%d : %s",
-				 pid, pgid, TEST_ERRNO, strerror(TEST_ERRNO));
-		} else {
-	    /***************************************************************
-	     * only perform functional verification if flag set (-f not given)
-	     ***************************************************************/
-			if (STD_FUNCTIONAL_TEST) {
-				/* No Verification test, yet... */
-				tst_resm(TPASS, "setpgid(%d, %d) returned %ld",
-					 pid, pgid, TEST_RETURN);
-			}
-		}
+		for (i = 0; i < TST_TOTAL; i++)
+			(*testfunc[i])();
 	}
 
-    /***************************************************************
-     * cleanup and exit
-     ***************************************************************/
 	cleanup();
 	tst_exit();
-
 }
 
-/***************************************************************
- * setup() - performs all ONE TIME setup for this test.
- ***************************************************************/
-void setup(void)
+static int wait4child(pid_t child)
 {
 	int status;
 
-	tst_sig(FORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
+	if (waitpid(child, &status, 0) == -1)
+		tst_resm(TBROK | TERRNO, "waitpid");
+	if (WIFEXITED(status))
+		return WEXITSTATUS(status);
+	else
+		return status;
+}
 
-	/*
-	 * Make sure current process is NOT a session or pgrp leader
-	 */
+static void setpgid_test1(void)
+{
+	int ret;
+	pid_t pgid, pid;
 
 	pgid = getpgrp();
 	pid = getpid();
 
+	/*
+	 * Make sure current process is NOT a session or pgrp leader
+	 */
 	if (pgid == pid) {
 		if ((pid = FORK_OR_VFORK()) == -1) {
-			tst_brkm(TBROK, cleanup,
-				 "fork() in setup() failed - errno %d", errno);
+			tst_brkm(TBROK | TERRNO, cleanup, "fork()");
 		}
 
-		if (pid != 0) {	/* parent - sits and waits */
-			wait(&status);
-			exit(WEXITSTATUS(status));
-		} else {	/* child - continues with test */
+		if (pid != 0) {
+			ret = wait4child(pid);
+		} else {
 			pid = getpid();
+			TEST(setpgid(pid, pgid));
+			if (TEST_RETURN == -1 || getpgrp() != pgid)
+				exit(1);
+			else
+				exit(0);
 		}
+	} else {
+		TEST(setpgid(pid, pgid));
+		if (TEST_RETURN == -1 || getpgrp() != pgid)
+			ret = 1;
+		else
+			ret = 0;
 	}
+
+	if (ret == 0)
+		tst_resm(TPASS, "test setpgid(%d, %d) success", pid, pgid);
+	else
+		tst_resm(TFAIL, "test setpgid(%d, %d) fail", pid, pgid);
 }
 
-/***************************************************************
- * cleanup() - performs all ONE TIME cleanup for this test at
- *		completion or premature exit.
- ***************************************************************/
-void cleanup(void)
+static void setup(void)
 {
-	/*
-	 * print timing stats if that option was specified.
-	 * print errno log if that option was specified.
-	 */
-	TEST_CLEANUP;
+	tst_sig(FORK, DEF_HANDLER, cleanup);
 
+	TEST_PAUSE;
+}
+
+static void cleanup(void)
+{
+	TEST_CLEANUP;
 }
-- 
1.8.2.1


------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [LTP] [PATCH 2/2] setpgid/setpgid01.c: add pid = 0 and pgid = 0 test
  2014-05-12  6:09 [LTP] [PATCH 1/2] setpgid/setpgid01.c: cleanup Xiaoguang Wang
@ 2014-05-12  6:09 ` Xiaoguang Wang
  2014-05-14 10:05 ` [LTP] [PATCH 1/2] setpgid/setpgid01.c: cleanup Jan Stancek
  1 sibling, 0 replies; 5+ messages in thread
From: Xiaoguang Wang @ 2014-05-12  6:09 UTC (permalink / raw)
  To: ltp-list

Signed-off-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
---
 testcases/kernel/syscalls/setpgid/setpgid01.c | 31 ++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/setpgid/setpgid01.c b/testcases/kernel/syscalls/setpgid/setpgid01.c
index d35f201..ed20f63 100644
--- a/testcases/kernel/syscalls/setpgid/setpgid01.c
+++ b/testcases/kernel/syscalls/setpgid/setpgid01.c
@@ -36,6 +36,7 @@
  * Description:
  * Verify that:
  *   1. Basic functionality test for setpgid(2).
+ *   2. Check proper functioning of setpgid(2) with pid = 0 and pgid = 0.
  */
 
 #include <errno.h>
@@ -52,7 +53,8 @@ static void cleanup(void);
 char *TCID = "setpgid01";
 
 static void setpgid_test1(void);
-static void (*testfunc[])(void) = { setpgid_test1};
+static void setpgid_test2(void);
+static void (*testfunc[])(void) = { setpgid_test1, setpgid_test2 };
 int TST_TOTAL = ARRAY_SIZE(testfunc);
 
 int main(int ac, char **av)
@@ -128,6 +130,33 @@ static void setpgid_test1(void)
 		tst_resm(TFAIL, "test setpgid(%d, %d) fail", pid, pgid);
 }
 
+static void setpgid_test2(void)
+{
+	int ret;
+	pid_t pgid, pid;
+
+	pid = FORK_OR_VFORK();
+	if (pid == -1)
+		tst_brkm(TBROK | TERRNO, cleanup, "fork()");
+
+	if (pid != 0) {
+		ret = wait4child(pid);
+	} else {
+		pid = getpid();
+		TEST(setpgid(0, 0));
+		pgid = getpgrp();
+		if (TEST_RETURN == -1 || pid != pgid)
+			exit(1);
+		else
+			exit(0);
+	}
+
+	if (ret == 0)
+		tst_resm(TPASS, "test setpgid(0, 0) success");
+	else
+		tst_resm(TFAIL, "test setpgid(0, 0) fail");
+}
+
 static void setup(void)
 {
 	tst_sig(FORK, DEF_HANDLER, cleanup);
-- 
1.8.2.1


------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [LTP] [PATCH 1/2] setpgid/setpgid01.c: cleanup
  2014-05-12  6:09 [LTP] [PATCH 1/2] setpgid/setpgid01.c: cleanup Xiaoguang Wang
  2014-05-12  6:09 ` [LTP] [PATCH 2/2] setpgid/setpgid01.c: add pid = 0 and pgid = 0 test Xiaoguang Wang
@ 2014-05-14 10:05 ` Jan Stancek
  2014-05-16  2:39   ` Xiaoguang Wang
  1 sibling, 1 reply; 5+ messages in thread
From: Jan Stancek @ 2014-05-14 10:05 UTC (permalink / raw)
  To: Xiaoguang Wang; +Cc: ltp-list



----- Original Message -----
> From: "Xiaoguang Wang" <wangxg.fnst@cn.fujitsu.com>
> To: ltp-list@lists.sourceforge.net
> Sent: Monday, 12 May, 2014 8:09:46 AM
> Subject: [LTP] [PATCH 1/2] setpgid/setpgid01.c: cleanup
> 
> Delete some useless comments.
> Do some code re-arrangement.
> Some cleanup.
> 
> Signed-off-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
> ---
>  testcases/kernel/syscalls/setpgid/setpgid01.c | 204
>  +++++++-------------------
>  1 file changed, 57 insertions(+), 147 deletions(-)
> 

> -	/*
> -	 * Make sure current process is NOT a session or pgrp leader
> -	 */
> +static void setpgid_test1(void)
> +{
> +	int ret;
> +	pid_t pgid, pid;
>  
>  	pgid = getpgrp();
>  	pid = getpid();
>  

Hi,

> +	/*
> +	 * Make sure current process is NOT a session or pgrp leader
> +	 */
>  	if (pgid == pid) {

What if we dropped the condition above and always make a child?
If we do that, then setpgid_test1() and setpgid_test2() are almost the same,
with the difference of arguments you pass to setpgid(), so there's a chance
to re-use some code.

Thinking about it a bit more, is there any reason we need a child process?

If it is pgrp leader, we create a child, which inherits parent's PGID and then
calls setpgid(0, pgid_of_parent)
If it's not a pgrp leader, we call setpgid(pid, current_pgid).

We always seem to call setpgid with same pgid as current PGID. Can that
fail in any scenario? Does it matter if it's a pgrp leader or not?

$ cat a.c
int main()
{
	printf("%d %d\n", getpid(), getpgrp());
	printf("%d\n", setpgid(getpid(), getpgrp()));
	return 0;
}

$ ./a.out 
22721 22721
0

Am I missing something?

Regards,
Jan

>  		if ((pid = FORK_OR_VFORK()) == -1) {
> -			tst_brkm(TBROK, cleanup,
> -				 "fork() in setup() failed - errno %d", errno);
> +			tst_brkm(TBROK | TERRNO, cleanup, "fork()");
>  		}
>  
> -		if (pid != 0) {	/* parent - sits and waits */
> -			wait(&status);
> -			exit(WEXITSTATUS(status));
> -		} else {	/* child - continues with test */
> +		if (pid != 0) {
> +			ret = wait4child(pid);
> +		} else {
>  			pid = getpid();
> +			TEST(setpgid(pid, pgid));
> +			if (TEST_RETURN == -1 || getpgrp() != pgid)
> +				exit(1);
> +			else
> +				exit(0);
>  		}
> +	} else {
> +		TEST(setpgid(pid, pgid));
> +		if (TEST_RETURN == -1 || getpgrp() != pgid)
> +			ret = 1;
> +		else
> +			ret = 0;
>  	}
> +
> +	if (ret == 0)
> +		tst_resm(TPASS, "test setpgid(%d, %d) success", pid, pgid);
> +	else
> +		tst_resm(TFAIL, "test setpgid(%d, %d) fail", pid, pgid);
>  }
>  
> -/***************************************************************
> - * cleanup() - performs all ONE TIME cleanup for this test at
> - *		completion or premature exit.
> - ***************************************************************/
> -void cleanup(void)
> +static void setup(void)
>  {
> -	/*
> -	 * print timing stats if that option was specified.
> -	 * print errno log if that option was specified.
> -	 */
> -	TEST_CLEANUP;
> +	tst_sig(FORK, DEF_HANDLER, cleanup);
>  
> +	TEST_PAUSE;
> +}
> +
> +static void cleanup(void)
> +{
> +	TEST_CLEANUP;
>  }
> --
> 1.8.2.1
> 
> 
> ------------------------------------------------------------------------------
> "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
> Instantly run your Selenium tests across 300+ browser/OS combos.
> Get unparalleled scalability from the best Selenium testing platform
> available
> Simple to use. Nothing to install. Get started now for free."
> http://p.sf.net/sfu/SauceLabs
> _______________________________________________
> Ltp-list mailing list
> Ltp-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ltp-list
> 

------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [LTP] [PATCH 1/2] setpgid/setpgid01.c: cleanup
  2014-05-14 10:05 ` [LTP] [PATCH 1/2] setpgid/setpgid01.c: cleanup Jan Stancek
@ 2014-05-16  2:39   ` Xiaoguang Wang
  2014-05-16  6:44     ` Jan Stancek
  0 siblings, 1 reply; 5+ messages in thread
From: Xiaoguang Wang @ 2014-05-16  2:39 UTC (permalink / raw)
  To: Jan Stancek; +Cc: ltp-list

Hi,

On 05/14/2014 06:05 PM, Jan Stancek wrote:
>
> ----- Original Message -----
>> From: "Xiaoguang Wang" <wangxg.fnst@cn.fujitsu.com>
>> To: ltp-list@lists.sourceforge.net
>> Sent: Monday, 12 May, 2014 8:09:46 AM
>> Subject: [LTP] [PATCH 1/2] setpgid/setpgid01.c: cleanup
>>
>> Delete some useless comments.
>> Do some code re-arrangement.
>> Some cleanup.
>>
>> Signed-off-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
>> ---
>>  testcases/kernel/syscalls/setpgid/setpgid01.c | 204
>>  +++++++-------------------
>>  1 file changed, 57 insertions(+), 147 deletions(-)
>>
>> -	/*
>> -	 * Make sure current process is NOT a session or pgrp leader
>> -	 */
>> +static void setpgid_test1(void)
>> +{
>> +	int ret;
>> +	pid_t pgid, pid;
>>  
>>  	pgid = getpgrp();
>>  	pid = getpid();
>>  
> Hi,
>
>> +	/*
>> +	 * Make sure current process is NOT a session or pgrp leader
>> +	 */
>>  	if (pgid == pid) {
> What if we dropped the condition above and always make a child?
> If we do that, then setpgid_test1() and setpgid_test2() are almost the same,
> with the difference of arguments you pass to setpgid(), so there's a chance
> to re-use some code.
>
> Thinking about it a bit more, is there any reason we need a child process?

For pid = 0 & pgid = 0 test, I think we should have tests in child process,
because in this case, according to setpgid()'s manpge, this will set
child process's PGID to its PID, we should verify this.

>
> If it is pgrp leader, we create a child, which inherits parent's PGID and then
> calls setpgid(0, pgid_of_parent)
> If it's not a pgrp leader, we call setpgid(pid, current_pgid).
>
> We always seem to call setpgid with same pgid as current PGID. Can that
> fail in any scenario? Does it matter if it's a pgrp leader or not?

Thanks for your explanation.
When I did this cleanup, I also did not know why to have this
setting, so I kept this setting. Now it seems it is useless, I
will send a new version, which would remove this 'pgid == pid' code, thanks.

Regards,
Xiaoguang Wang

>
> $ cat a.c
> int main()
> {
> 	printf("%d %d\n", getpid(), getpgrp());
> 	printf("%d\n", setpgid(getpid(), getpgrp()));
> 	return 0;
> }
>
> $ ./a.out 
> 22721 22721
> 0
>
> Am I missing something?
>
> Regards,
> Jan
>
>>  		if ((pid = FORK_OR_VFORK()) == -1) {
>> -			tst_brkm(TBROK, cleanup,
>> -				 "fork() in setup() failed - errno %d", errno);
>> +			tst_brkm(TBROK | TERRNO, cleanup, "fork()");
>>  		}
>>  
>> -		if (pid != 0) {	/* parent - sits and waits */
>> -			wait(&status);
>> -			exit(WEXITSTATUS(status));
>> -		} else {	/* child - continues with test */
>> +		if (pid != 0) {
>> +			ret = wait4child(pid);
>> +		} else {
>>  			pid = getpid();
>> +			TEST(setpgid(pid, pgid));
>> +			if (TEST_RETURN == -1 || getpgrp() != pgid)
>> +				exit(1);
>> +			else
>> +				exit(0);
>>  		}
>> +	} else {
>> +		TEST(setpgid(pid, pgid));
>> +		if (TEST_RETURN == -1 || getpgrp() != pgid)
>> +			ret = 1;
>> +		else
>> +			ret = 0;
>>  	}
>> +
>> +	if (ret == 0)
>> +		tst_resm(TPASS, "test setpgid(%d, %d) success", pid, pgid);
>> +	else
>> +		tst_resm(TFAIL, "test setpgid(%d, %d) fail", pid, pgid);
>>  }
>>  
>> -/***************************************************************
>> - * cleanup() - performs all ONE TIME cleanup for this test at
>> - *		completion or premature exit.
>> - ***************************************************************/
>> -void cleanup(void)
>> +static void setup(void)
>>  {
>> -	/*
>> -	 * print timing stats if that option was specified.
>> -	 * print errno log if that option was specified.
>> -	 */
>> -	TEST_CLEANUP;
>> +	tst_sig(FORK, DEF_HANDLER, cleanup);
>>  
>> +	TEST_PAUSE;
>> +}
>> +
>> +static void cleanup(void)
>> +{
>> +	TEST_CLEANUP;
>>  }
>> --
>> 1.8.2.1
>>
>>
>> ------------------------------------------------------------------------------
>> "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
>> Instantly run your Selenium tests across 300+ browser/OS combos.
>> Get unparalleled scalability from the best Selenium testing platform
>> available
>> Simple to use. Nothing to install. Get started now for free."
>> http://p.sf.net/sfu/SauceLabs
>> _______________________________________________
>> Ltp-list mailing list
>> Ltp-list@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/ltp-list
>>
> .
>


------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [LTP] [PATCH 1/2] setpgid/setpgid01.c: cleanup
  2014-05-16  2:39   ` Xiaoguang Wang
@ 2014-05-16  6:44     ` Jan Stancek
  0 siblings, 0 replies; 5+ messages in thread
From: Jan Stancek @ 2014-05-16  6:44 UTC (permalink / raw)
  To: Xiaoguang Wang; +Cc: ltp-list





----- Original Message -----
> From: "Xiaoguang Wang" <wangxg.fnst@cn.fujitsu.com>
> To: "Jan Stancek" <jstancek@redhat.com>
> Cc: ltp-list@lists.sourceforge.net
> Sent: Friday, 16 May, 2014 4:39:49 AM
> Subject: Re: [LTP] [PATCH 1/2] setpgid/setpgid01.c: cleanup
> 

> >>  
> > Hi,
> >
> >> +	/*
> >> +	 * Make sure current process is NOT a session or pgrp leader
> >> +	 */
> >>  	if (pgid == pid) {
> > What if we dropped the condition above and always make a child?
> > If we do that, then setpgid_test1() and setpgid_test2() are almost the
> > same,
> > with the difference of arguments you pass to setpgid(), so there's a chance
> > to re-use some code.
> >
> > Thinking about it a bit more, is there any reason we need a child process?
> 
> For pid = 0 & pgid = 0 test, I think we should have tests in child process,
> because in this case, according to setpgid()'s manpge, this will set
> child process's PGID to its PID, we should verify this.

"If pgid is zero, then the PGID of the process specified by pid is made the
same as its process ID."

I see. So, for "setpgid(0, 0);" it makes a difference and it
actually changes PGID to a different value. I'll have a look at v2
later today.

Regards,
Jan

------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-05-16  6:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-12  6:09 [LTP] [PATCH 1/2] setpgid/setpgid01.c: cleanup Xiaoguang Wang
2014-05-12  6:09 ` [LTP] [PATCH 2/2] setpgid/setpgid01.c: add pid = 0 and pgid = 0 test Xiaoguang Wang
2014-05-14 10:05 ` [LTP] [PATCH 1/2] setpgid/setpgid01.c: cleanup Jan Stancek
2014-05-16  2:39   ` Xiaoguang Wang
2014-05-16  6:44     ` Jan Stancek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox