[BACK]Return to job.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / make

Diff for /src/usr.bin/make/job.c between version 1.136 and 1.137

version 1.136, 2015/07/28 14:22:26 version 1.137, 2017/01/21 11:30:11
Line 156 
Line 156 
 static void notice_signal(int);  static void notice_signal(int);
 static void setup_all_signals(void);  static void setup_all_signals(void);
 static const char *really_kill(Job *, int);  static const char *really_kill(Job *, int);
 static void kill_with_doas_maybe(pid_t, int, const char *);  
 static void debug_kill_printf(const char *, ...);  static void debug_kill_printf(const char *, ...);
 static void debug_vprintf(const char *, va_list);  static void debug_vprintf(const char *, va_list);
 static void may_remove_target(Job *);  static void may_remove_target(Job *);
Line 168 
Line 167 
   
 const char *    basedirectory = NULL;  const char *    basedirectory = NULL;
   
 static void  
 kill_with_doas_maybe(pid_t pid, int signo, const char *p)  
 {  
         char buf[32]; /* largely enough */  
         int sudo;  
   
         for (;*p != '\0'; p++) {  
                 if (*p == 's')  
                         sudo = 1;  
                 else if (*p == 'd')  
                         sudo = 0;  
                 else  
                         continue;  
                 if (sudo && p[1] != 'u' || !sudo && p[1] != 'o')  
                         continue;  
                 p++;  
                 if (sudo && p[1] != 'd' || !sudo && p[1] != 'a')  
                         continue;  
                 p++;  
                 if (sudo && p[1] != 'o' || !sudo && p[1] != 's')  
                         continue;  
                 snprintf(buf, sizeof buf, "%s -n /bin/kill -%d %ld",  
                     sudo ? "sudo" : "doas",  
                     signo, (long)pid);  
                 debug_kill_printf("trying to kill with %s", buf);  
                 system(buf);  
                 return;  
         }  
   
 }  
   
 static const char *  static const char *
 really_kill(Job *job, int signo)  really_kill(Job *job, int signo)
 {  {
Line 214 
Line 182 
         if (errno == ESRCH) {          if (errno == ESRCH) {
                 job->flags |= JOB_LOST;                  job->flags |= JOB_LOST;
                 return "not found";                  return "not found";
         } else if (errno == EPERM) {  
                 kill_with_doas_maybe(pid, signo, job->cmd);  
                 return "";  
         } else          } else
                 return "should not happen";                  return "should not happen";
 }  }

Legend:
Removed from v.1.136  
changed lines
  Added in v.1.137