public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/2] lib: move create_sig_proc() into newlib
@ 2016-11-16 16:18 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 14:57 ` [LTP] [PATCH 1/2] lib: move create_sig_proc() into newlib Cyril Hrubis
  0 siblings, 2 replies; 6+ messages in thread
From: Petr Vorel @ 2016-11-16 16:18 UTC (permalink / raw)
  To: ltp

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 include/tst_sig_proc.h                    | 23 ++++++++++++++++++
 lib/tst_sig_proc.c                        | 39 +++++++++++++++++++++++++++++++
 testcases/kernel/syscalls/ppoll/ppoll01.c | 20 +---------------
 3 files changed, 63 insertions(+), 19 deletions(-)
 create mode 100644 include/tst_sig_proc.h
 create mode 100644 lib/tst_sig_proc.c

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 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>
+
+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>
+ *
+ * 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>
+
+#define TST_NO_DEFAULT_MAIN
+#include "tst_test.h"
+
+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


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

end of thread, other threads:[~2016-11-22  8:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [LTP] [PATCH 1/2] lib: move create_sig_proc() into newlib Cyril Hrubis
2016-11-22  7:09   ` Petr Vorel
2016-11-22  8:02     ` Cyril Hrubis

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