All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] Remove the signal-waiting logic from create_sig_proc()
@ 2009-06-08 11:29 Jiri Palecek
  2009-06-09 18:25 ` Subrata Modak
  0 siblings, 1 reply; 2+ messages in thread
From: Jiri Palecek @ 2009-06-08 11:29 UTC (permalink / raw)
  To: ltp-list

 In create_sig_proc, the child process waits for the parent to wake it
 with a signal. This doesn't actually solve anything, and the
 implementation with pause() syscall is inherently racy (the race
 results in a deadlock). This patch removes it; it doesn't make the
 function race-free (it's possible the child will send the signal
 before the parent had chance to run), but this is the best you can
 get.

Regards
    Jiri Palecek

Signed-off-by: Jiri Palecek <jpalecek@web.de>
---
 testcases/kernel/syscalls/utils/common_j_h.c |   10 ----------
 1 files changed, 0 insertions(+), 10 deletions(-)

diff --git a/testcases/kernel/syscalls/utils/common_j_h.c b/testcases/kernel/syscalls/utils/common_j_h.c
index cda3198..d122ff9 100644
--- a/testcases/kernel/syscalls/utils/common_j_h.c
+++ b/testcases/kernel/syscalls/utils/common_j_h.c
@@ -102,23 +102,14 @@ int cleanup_euid(uid_t old_uid)
 /*
  * Generate a child process which will send a signal
  */
-static void sighandler_for_sig_proc(int sig)
-{
-	if (sig == SIGUSR2)
-		return;
-	return;
-}
-
 pid_t create_sig_proc(unsigned long usec, int sig)
 {
 	pid_t pid, cpid;
 
-	signal(SIGUSR2, sighandler_for_sig_proc);
 	pid = getpid();
 	cpid = fork();
 	switch (cpid) {
 	case 0:
-		pause();
 		usleep(usec);
 		kill(pid, sig);
 		_exit(0);
@@ -127,7 +118,6 @@ pid_t create_sig_proc(unsigned long usec, int sig)
 		EPRINTF("fork failed.\n");
 		return cpid;
 	default:
-		kill(cpid, SIGUSR2);
 		return cpid;
 	}
 }
-- 
1.6.2.4


------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
looking to deploy the next generation of Solaris that includes the latest 
innovations from Sun and the OpenSource community. Download a copy and 
enjoy capabilities such as Networking, Storage and Virtualization. 
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH] Remove the signal-waiting logic from create_sig_proc()
  2009-06-08 11:29 [LTP] [PATCH] Remove the signal-waiting logic from create_sig_proc() Jiri Palecek
@ 2009-06-09 18:25 ` Subrata Modak
  0 siblings, 0 replies; 2+ messages in thread
From: Subrata Modak @ 2009-06-09 18:25 UTC (permalink / raw)
  To: Jiri Palecek; +Cc: ltp-list

On Mon, 2009-06-08 at 13:29 +0200, Jiri Palecek wrote: 
> In create_sig_proc, the child process waits for the parent to wake it
>  with a signal. This doesn't actually solve anything, and the
>  implementation with pause() syscall is inherently racy (the race
>  results in a deadlock). This patch removes it; it doesn't make the
>  function race-free (it's possible the child will send the signal
>  before the parent had chance to run), but this is the best you can
>  get.
> 
> Regards
>     Jiri Palecek
> 
> Signed-off-by: Jiri Palecek <jpalecek@web.de>

Thanks.

Regards--
Subrata

> ---
>  testcases/kernel/syscalls/utils/common_j_h.c |   10 ----------
>  1 files changed, 0 insertions(+), 10 deletions(-)
> 
> diff --git a/testcases/kernel/syscalls/utils/common_j_h.c b/testcases/kernel/syscalls/utils/common_j_h.c
> index cda3198..d122ff9 100644
> --- a/testcases/kernel/syscalls/utils/common_j_h.c
> +++ b/testcases/kernel/syscalls/utils/common_j_h.c
> @@ -102,23 +102,14 @@ int cleanup_euid(uid_t old_uid)
>  /*
>   * Generate a child process which will send a signal
>   */
> -static void sighandler_for_sig_proc(int sig)
> -{
> -	if (sig == SIGUSR2)
> -		return;
> -	return;
> -}
> -
>  pid_t create_sig_proc(unsigned long usec, int sig)
>  {
>  	pid_t pid, cpid;
> 
> -	signal(SIGUSR2, sighandler_for_sig_proc);
>  	pid = getpid();
>  	cpid = fork();
>  	switch (cpid) {
>  	case 0:
> -		pause();
>  		usleep(usec);
>  		kill(pid, sig);
>  		_exit(0);
> @@ -127,7 +118,6 @@ pid_t create_sig_proc(unsigned long usec, int sig)
>  		EPRINTF("fork failed.\n");
>  		return cpid;
>  	default:
> -		kill(cpid, SIGUSR2);
>  		return cpid;
>  	}
>  }


------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

end of thread, other threads:[~2009-06-09 18:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-08 11:29 [LTP] [PATCH] Remove the signal-waiting logic from create_sig_proc() Jiri Palecek
2009-06-09 18:25 ` Subrata Modak

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.