aboutsummaryrefslogtreecommitdiff
path: root/src/testzzuf/socat.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testzzuf/socat.c')
-rw-r--r--src/testzzuf/socat.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/src/testzzuf/socat.c b/src/testzzuf/socat.c
index 72089a6d..07cbf464 100644
--- a/src/testzzuf/socat.c
+++ b/src/testzzuf/socat.c
@@ -67,27 +67,27 @@ zzuf_socat_start ()
67 }; 67 };
68 zzuf_pid = fork (); 68 zzuf_pid = fork ();
69 if (zzuf_pid == -1) 69 if (zzuf_pid == -1)
70 { 70 {
71 fprintf (stderr, "fork failed: %s\n", strerror (errno)); 71 fprintf (stderr, "fork failed: %s\n", strerror (errno));
72 exit (1); 72 exit (1);
73 } 73 }
74 if (zzuf_pid != 0) 74 if (zzuf_pid != 0)
75 {
76 (void) sleep (1); /* allow zzuf and socat to start */
77 status = 0;
78 if (0 < waitpid (zzuf_pid, &status, WNOHANG))
75 { 79 {
76 (void)sleep (1); /* allow zzuf and socat to start */ 80 if (WIFEXITED (status))
77 status = 0; 81 fprintf (stderr,
78 if (0 < waitpid (zzuf_pid, &status, WNOHANG)) 82 "zzuf died with status code %d!\n",
79 { 83 WEXITSTATUS (status));
80 if (WIFEXITED (status)) 84 if (WIFSIGNALED (status))
81 fprintf (stderr, 85 fprintf (stderr,
82 "zzuf died with status code %d!\n", 86 "zzuf died from signal %d!\n", WTERMSIG (status));
83 WEXITSTATUS (status)); 87 exit (1);
84 if (WIFSIGNALED (status))
85 fprintf (stderr,
86 "zzuf died from signal %d!\n", WTERMSIG (status));
87 exit (1);
88 }
89 return;
90 } 88 }
89 return;
90 }
91 setpgid (0, 0); 91 setpgid (0, 0);
92 execvp ("zzuf", args); 92 execvp ("zzuf", args);
93 fprintf (stderr, "execution of `zzuf' failed: %s\n", strerror (errno)); 93 fprintf (stderr, "execution of `zzuf' failed: %s\n", strerror (errno));
@@ -100,13 +100,13 @@ zzuf_socat_stop ()
100{ 100{
101 int status; 101 int status;
102 if (zzuf_pid != 0) 102 if (zzuf_pid != 0)
103 { 103 {
104 if (0 != killpg (zzuf_pid, SIGINT)) 104 if (0 != killpg (zzuf_pid, SIGINT))
105 fprintf (stderr, "Failed to killpg: %s\n", strerror (errno)); 105 fprintf (stderr, "Failed to killpg: %s\n", strerror (errno));
106 kill (zzuf_pid, SIGINT); 106 kill (zzuf_pid, SIGINT);
107 waitpid (zzuf_pid, &status, 0); 107 waitpid (zzuf_pid, &status, 0);
108 (void)sleep (1); /* allow socat to also die in peace */ 108 (void) sleep (1); /* allow socat to also die in peace */
109 } 109 }
110} 110}
111 111
112/* end of socat.c */ 112/* end of socat.c */