[hackers] [scc] [driver] add checktool() || Quentin Rameau

From: <git_AT_suckless.org>
Date: Sat, 4 Jun 2016 13:02:20 +0200 (CEST)

commit 015c9f4466d5dccbfdd11e0c250c8445f17d61e5
Author: Quentin Rameau <quinq_AT_fifth.space>
AuthorDate: Sat Jun 4 12:04:04 2016 +0200
Commit: Quentin Rameau <quinq_AT_fifth.space>
CommitDate: Sat Jun 4 12:04:04 2016 +0200

    [driver] add checktool()
    
    Move from build() the check of spawned tools to checktool()

diff --git a/driver/posix/scc.c b/driver/posix/scc.c
index eedd0b5..7988707 100644
--- a/driver/posix/scc.c
+++ b/driver/posix/scc.c
_AT_@ -236,10 +236,27 @@ toolfor(char *file)
 }
 
 static void
+checktool(int tool)
+{
+ struct tool *t = &tools[tool];
+ int st;
+
+ if (!t->pid)
+ return;
+
+ if (waitpid(t->pid, &st, 0) < 0 ||
+ !WIFEXITED(st) || WEXITSTATUS(st) != 0) {
+ failedtool = tool;
+ exit(-1);
+ }
+
+ t->pid = 0;
+}
+
+static void
 build(char *file)
 {
- pid_t pid;
- int i, st, tool, out, keepfile;
+ int i, tool, out, keepfile;
         static int preout;
 
         for (tool = toolfor(file); tool < NR_TOOLS; tool = out) {
_AT_@ -282,19 +299,8 @@ build(char *file)
                 spawn(settool(inittool(tool), file, out));
         }
 
- for (i = 0; i < NR_TOOLS; ++i) {
- if ((pid = tools[i].pid) == 0)
- continue;
- if (waitpid(pid, &st, 0) < 0) {
- failedtool = i;
- exit(-1);
- }
- tools[i].pid = 0;
- if (!WIFEXITED(st) || WEXITSTATUS(st) != 0) {
- failedtool = i;
- exit(-1);
- }
- }
+ for (i = 0; i < NR_TOOLS; ++i)
+ checktool(i);
 
         cleanup();
 }
Received on Sat Jun 04 2016 - 13:02:20 CEST

This archive was generated by hypermail 2.3.0 : Sat Jun 04 2016 - 13:12:13 CEST