[hackers] [scc] [driver] loop over tools instead of processing each one || Quentin Rameau

From: <git_AT_suckless.org>
Date: Mon, 30 May 2016 11:15:22 +0200 (CEST)

commit a11839f8071c98ec980ac43d51431044f2ea6f6b
Author: Quentin Rameau <quinq_AT_fifth.space>
AuthorDate: Mon May 30 11:13:48 2016 +0200
Commit: Quentin Rameau <quinq_AT_fifth.space>
CommitDate: Mon May 30 11:13:48 2016 +0200

    [driver] loop over tools instead of processing each one

diff --git a/driver/posix/scc.c b/driver/posix/scc.c
index 5ce20e9..eec84cb 100644
--- a/driver/posix/scc.c
+++ b/driver/posix/scc.c
_AT_@ -20,6 +20,7 @@ enum {
         CC1,
         CC2,
         QBE,
+ NR_TOOLS,
 };
 
 static struct {
_AT_@ -41,12 +42,12 @@ static char *arch;
 static void
 terminate(void)
 {
- if (tools[CC1].pid)
- kill(tools[CC1].pid, SIGTERM);
- if (tools[CC2].pid)
- kill(tools[CC2].pid, SIGTERM);
- if (tools[QBE].pid)
- kill(tools[QBE].pid, SIGTERM);
+ int i;
+
+ for (i = 0; i < NR_TOOLS; ++i) {
+ if (tools[i].pid)
+ kill(tools[i].pid, SIGTERM);
+ }
 }
 
 int
_AT_@ -148,15 +149,11 @@ main(int argc, char *argv[])
                 spawn(settool(QBE, 0));
         }
 
- for (i = 0; i < 3; ++i) {
+ for (i = 0; i < NR_TOOLS; ++i) {
                 if ((pid = wait(&st)) < 0)
                         break;
- if (pid == tools[CC1].pid)
- tools[CC1].pid = 0;
- else if (pid == tools[CC2].pid)
- tools[CC2].pid = 0;
- else if (pid == tools[QBE].pid)
- tools[QBE].pid = 0;
+ if (pid == tools[i].pid)
+ tools[i].pid = 0;
                 if (!WIFEXITED(st) || WEXITSTATUS(st) != 0)
                         exit(-1);
         }
Received on Mon May 30 2016 - 11:15:22 CEST

This archive was generated by hypermail 2.3.0 : Mon May 30 2016 - 11:24:13 CEST