public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 1/2] lib: move create_sig_proc() into newlib
Date: Mon, 21 Nov 2016 15:57:02 +0100	[thread overview]
Message-ID: <20161121145701.GF25334@rei.lan> (raw)
In-Reply-To: <20161116161833.16910-1-pvorel@suse.cz>

Hi!
> diff --git a/include/tst_sig_proc.h b/include/tst_sig_proc.h
> new file mode 100644
> index 0000000..bc918eb
> --- /dev/null
> +++ b/include/tst_sig_proc.h
> @@ -0,0 +1,23 @@
> +/*
> + * Copyright (c) 2016 Cyril Hrubis <chrubis@suse.cz>
                      ^
		      This should be you, or Linux Test Project, as it
		      is in several other files

> + * This program is free software;  you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY;  without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
> + * the GNU General Public License for more details.
> + */
> +
> +#ifndef TST_SIG_PROC_H__
> +#define TST_SIG_PROC_H__
> +
> +#include <sys/types.h>
> +#include <unistd.h>

The sys/types.h is enough to get the pid_t defined here.

> +pid_t create_sig_proc(int sig, int count, unsigned int usec);
> +
> +#endif	/* TST_SIG_PROC_H__ */
> diff --git a/lib/tst_sig_proc.c b/lib/tst_sig_proc.c
> new file mode 100644
> index 0000000..a5f6c54
> --- /dev/null
> +++ b/lib/tst_sig_proc.c
> @@ -0,0 +1,39 @@
> +/*
> + * Copyright (c) 2016 Cyril Hrubis <chrubis@suse.cz>

Here as well.

> + * This program is free software;  you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY;  without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
> + * the GNU General Public License for more details.
> + */
> +
> +#include <sys/types.h>
> +#include <unistd.h>
> +#include <stdlib.h>

You should include the tst_sig_proc.h header here, if nothing else that
will force that the function definitions in header and source are in
sync.

> +#define TST_NO_DEFAULT_MAIN
> +#include "tst_test.h"

Shouldn't be including tst_safe_macros.h here enough?

> +pid_t create_sig_proc(int sig, int count, unsigned int usec)
> +{
> +	pid_t pid, cpid;
> +
> +	pid = getpid();
> +	cpid = SAFE_FORK();
> +
> +	if (cpid == 0) {
> +		while (count-- > 0) {
> +			usleep(usec);
> +			if (kill(pid, sig) == -1)
> +				break;
> +		}
> +		exit(0);
> +	}
> +
> +	return cpid;
> +}
> diff --git a/testcases/kernel/syscalls/ppoll/ppoll01.c b/testcases/kernel/syscalls/ppoll/ppoll01.c
> index a5815b3..8d6d7e7 100644
> --- a/testcases/kernel/syscalls/ppoll/ppoll01.c
> +++ b/testcases/kernel/syscalls/ppoll/ppoll01.c
> @@ -28,6 +28,7 @@
>  #include <sys/wait.h>
>  #include "linux_syscall_numbers.h"
>  #include "ltp_signal.h"
> +#include "tst_sig_proc.h"
>  #include "tst_test.h"
>  
>  /* Older versions of glibc don't publish this constant's value. */
> @@ -205,25 +206,6 @@ static void cleanup(void)
>  		close(fd1);
>  }
>  
> -static pid_t create_sig_proc(int sig, int count, unsigned int usec)
> -{
> -	pid_t pid, cpid;
> -
> -	pid = getpid();
> -	cpid = SAFE_FORK();
> -
> -	if (cpid == 0) {
> -		while (count-- > 0) {
> -			usleep(usec);
> -			if (kill(pid, sig) == -1)
> -				break;
> -		}
> -		exit(0);
> -	}
> -
> -	return cpid;
> -}
> -
>  static void do_test(unsigned int i)
>  {
>  	pid_t pid = 0;
> -- 
> 2.10.2
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz

  parent reply	other threads:[~2016-11-21 14:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-16 16:18 [LTP] [PATCH 1/2] lib: move create_sig_proc() into newlib Petr Vorel
2016-11-16 16:18 ` [LTP] [PATCH 2/2] testcases/clock_nanosleep01: convert to use new test library API Petr Vorel
2016-11-21 15:23   ` Cyril Hrubis
2016-11-21 14:57 ` Cyril Hrubis [this message]
2016-11-22  7:09   ` [LTP] [PATCH 1/2] lib: move create_sig_proc() into newlib Petr Vorel
2016-11-22  8:02     ` Cyril Hrubis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161121145701.GF25334@rei.lan \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox