Skip to contentSkip to conversation

recvmsg01: kill child only if one was forked

PATCH In review Jan Stancek 3 participants 7 messages Nov 7, 2011 – Nov 16, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 recvmsg01: kill child only if one was forked

If start_server() fails, then pid will end up with -1 and cleanup() will do kill(-1, SIGKILL), which kills everything this process can kill.

Change the test to kill pid (child) only when it successfully creates one.

---
 testcases/kernel/syscalls/recvmsg/recvmsg01.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
testcases/kernel/syscalls/recvmsg/recvmsg01.c +3 -2
index ba3b0fd..41d0726 100644
@@ -281,7 +281,8 @@ void setup(void)
 
 void cleanup(void)
 {
-	(void)kill(pid, SIGKILL);	/* kill server */
+	if (pid > 0)
+		(void)kill(pid, SIGKILL);	/* kill server */
 	if (tmpsunpath[0] != '\0')
 		(void)unlink(tmpsunpath);
 	TEST_CLEANUP;
@@ -528,4 +529,4 @@ void sender(int fd)
 	(void)sendmsg(fd, &mh, 0);
 	(void)close(tfd);
 	(void)unlink(tmpfn);
-}
\ No newline at end of file
+}

------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1

_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#1 lore raw
Quoted 8 lines · Jan Stancek

If start_server() fails, then pid will end up with -1 and cleanup() will do kill(-1, SIGKILL), which kills everything this process can kill.

Change the test to kill pid (child) only when it successfully creates one.

Yeah, but this can't fix the problem in this case?

recvmsg01    1  TBROK  :  server bind failed: errno=???(98): Address already in use
recvmsg01    2  TBROK  :  Remaining cases broken

Thanks
-Wanlong Gao

Quoted 6 lines
---
  testcases/kernel/syscalls/recvmsg/recvmsg01.c |    5 +++--
  1 files changed, 3 insertions(+), 2 deletions(-)

------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#2 lore raw

----- Original Message -----

Quoted 18 lines

From: "Wanlong Gao" <[email protected]>
To: "Jan Stancek" <[email protected]>
Cc: [email protected]
Sent: Tuesday, November 8, 2011 4:07:56 AM
Subject: Re: [LTP] [PATCH] recvmsg01: kill child only if one was forked

Quoted 8 lines · Jan Stancek

If start_server() fails, then pid will end up with -1 and cleanup() will do kill(-1, SIGKILL), which kills everything this process can kill.

Change the test to kill pid (child) only when it successfully creates one.

Quoted 6 lines

Yeah, but this can't fix the problem in this case?

recvmsg01 1 TBROK : server bind failed: errno=???(98): Address
already in use
recvmsg01 2 TBROK : Remaining cases broken

I'm not sure I follow you here.
In case you described start_server() returns -1, so pid = -1, and cleanup won't do kill(-1, SIGKILL).

Regards,
Jan

Quoted 13 lines

Thanks
-Wanlong Gao

Quoted 6 lines
---
  testcases/kernel/syscalls/recvmsg/recvmsg01.c |    5 +++--
  1 files changed, 3 insertions(+), 2 deletions(-)

------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#3 lore raw
Quoted 23 lines · Jan Stancek

----- Original Message -----

Quoted 20 lines

From: "Wanlong Gao" <[email protected]>
To: "Jan Stancek" <[email protected]>
Cc: [email protected]
Sent: Tuesday, November 8, 2011 4:07:56 AM
Subject: Re: [LTP] [PATCH] recvmsg01: kill child only if one was forked

Quoted 8 lines · Jan Stancek

If start_server() fails, then pid will end up with -1 and cleanup() will do kill(-1, SIGKILL), which kills everything this process can kill.

Change the test to kill pid (child) only when it successfully creates one.

Yeah, but this can't fix the problem in this case?

Quoted 9 lines
Quoted 4 lines

recvmsg01 1 TBROK : server bind failed: errno=???(98): Address
already in use
recvmsg01 2 TBROK : Remaining cases broken

I'm not sure I follow you here.
In case you described start_server() returns -1, so pid = -1, and cleanup won't do kill(-1, SIGKILL).

Yeah, I understood you.

But we wanna fix the case to TPASS but not TBROK, do we? So, I mean that the issues of this case is not only what you said.

Thanks
-Wanlong Gao

------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#4 lore raw

----- Original Message -----

Quoted 44 lines

From: "Wanlong Gao" <[email protected]>
To: "Jan Stancek" <[email protected]>
Cc: [email protected]
Sent: Tuesday, November 8, 2011 8:21:01 AM
Subject: Re: [LTP] [PATCH] recvmsg01: kill child only if one was forked

Quoted 30 lines · Jan Stancek

----- Original Message -----

Quoted 19 lines

From: "Wanlong Gao" <[email protected]>
To: "Jan Stancek" <[email protected]>
Cc: [email protected]
Sent: Tuesday, November 8, 2011 4:07:56 AM
Subject: Re: [LTP] [PATCH] recvmsg01: kill child only if one was forked

Quoted 8 lines · Jan Stancek

If start_server() fails, then pid will end up with -1 and cleanup() will do kill(-1, SIGKILL), which kills everything this process can kill.

Change the test to kill pid (child) only when it successfully creates one.

Quoted 7 lines

Yeah, but this can't fix the problem in this case?

recvmsg01 1 TBROK : server bind failed: errno=???(98):
Address
already in use
recvmsg01 2 TBROK : Remaining cases broken

Quoted 4 lines

I'm not sure I follow you here.
In case you described start_server() returns -1, so pid = -1, and cleanup won't do kill(-1, SIGKILL).

Quoted 3 lines

Yeah, I understood you.

But we wanna fix the case to TPASS but not TBROK, do we?

True, but until we have such fix, we should at least make it less annoying when it fails.

Quoted 1 line

So, I mean that the issues of this case is not only what you said.

I didn't actually get to see yet what those are, because those TBROK messages didn't make it to log:

<<<test_start>>>
tag=recvmsg01 stime=1320555319
cmdline="recvmsg01"
contacts=""
analysis=exit
<<<test_output>>>
<<<execution_status>>>
initiation_status="ok"
duration=0 termination_type=signaled termination_id=9 corefile=no cutime=0 cstime=0
<<<test_end>>>

Regards,
Jan

------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#5 lore raw
Quoted 71 lines · Jan Stancek

----- Original Message -----

Quoted 44 lines

From: "Wanlong Gao" <[email protected]>
To: "Jan Stancek" <[email protected]>
Cc: [email protected]
Sent: Tuesday, November 8, 2011 8:21:01 AM
Subject: Re: [LTP] [PATCH] recvmsg01: kill child only if one was forked

Quoted 30 lines · Jan Stancek

----- Original Message -----

Quoted 19 lines

From: "Wanlong Gao" <[email protected]>
To: "Jan Stancek" <[email protected]>
Cc: [email protected]
Sent: Tuesday, November 8, 2011 4:07:56 AM
Subject: Re: [LTP] [PATCH] recvmsg01: kill child only if one was forked

Quoted 8 lines · Jan Stancek

If start_server() fails, then pid will end up with -1 and cleanup() will do kill(-1, SIGKILL), which kills everything this process can kill.

Change the test to kill pid (child) only when it successfully creates one.

Quoted 7 lines

Yeah, but this can't fix the problem in this case?

recvmsg01 1 TBROK : server bind failed: errno=???(98):
Address
already in use
recvmsg01 2 TBROK : Remaining cases broken

Quoted 4 lines

I'm not sure I follow you here.
In case you described start_server() returns -1, so pid = -1, and cleanup won't do kill(-1, SIGKILL).

Quoted 3 lines

Yeah, I understood you.

But we wanna fix the case to TPASS but not TBROK, do we?

True, but until we have such fix, we should at least make it less annoying when it fails.

Quoted 1 line

So, I mean that the issues of this case is not only what you said.

I didn't actually get to see yet what those are, because those TBROK messages didn't make it to log:

<<<test_start>>>
tag=recvmsg01 stime=1320555319
cmdline="recvmsg01"
contacts=""
analysis=exit
<<<test_output>>>
<<<execution_status>>>
initiation_status="ok"
duration=0 termination_type=signaled termination_id=9 corefile=no cutime=0 cstime=0
<<<test_end>>>

Quoted 3 lines

Regards,
Jan

You can do like this:
while [ $? -eq 0 ]; do ./recvmsg01; done

Then you can see the TBROK message.

-Wanlong Gao

------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#6 lore raw
In reply to Jan Stancek

Hi!

Quoted 6 lines

If start_server() fails, then pid will end up with -1 and cleanup() will do kill(-1, SIGKILL), which kills everything this process can kill.

Change the test to kill pid (child) only when it successfully creates one.

Good catch, commited.

Signature · 12 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list