bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bash 2.05 porting nit: process-IDs may not fit in 'int'


From: Paul Eggert
Subject: Bash 2.05 porting nit: process-IDs may not fit in 'int'
Date: Sun, 29 Apr 2001 18:23:38 -0700 (PDT)

Configuration Information [Automatically generated, do not change]:
Machine: sparc
OS: solaris2.7
Compiler: cc -xarch=v9
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='sparc' 
-DCONF_OSTYPE='solaris2.7' -DCONF_MACHTYPE='sparc-sun-solaris2.7' 
-DCONF_VENDOR='sun' -DSHELL  -DHAVE_CONFIG_H  -D_LARGEFILE_SOURCE 
-D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -I.  -I.. -I../include -I../lib 
-I/tmp/prefix/include -g
uname output: SunOS sic.twinsun.com 5.7 Generic_106541-15 sun4u sparc 
SUNW,UltraSPARC-IIi-Engine
Machine Type: sparc-sun-solaris2.7

Bash Version: 2.05
Patch Level: 0
Release Status: release

Description:
        In three builtins, Bash 2.05 assumes that valid process-IDs can fit
        into 'int', which POSIX.1 does not guarantee.

Repeat-By:


Fix:
2001-04-29  Paul Eggert  <address@hidden>

        * builtins/jobs.def (disown_builtin): Don't assume pids fit in 'int'.
        * builtins/kill.def (kill_builtin): Likewise.
        * builtins/wait.def (wait_builtin): Likewise.

===================================================================
RCS file: builtins/jobs.def,v
retrieving revision 2.5
retrieving revision 2.5.0.1
diff -pu -r2.5 -r2.5.0.1
--- builtins/jobs.def   1999/08/05 11:43:05     2.5
+++ builtins/jobs.def   2001/04/30 01:17:51     2.5.0.1
@@ -256,9 +256,11 @@ disown_builtin (list)
 
   do
     {
+      long value;
       BLOCK_CHILD (set, oset);
-      job = (list && all_digits(list->word->word))
-               ? get_job_by_pid (atoi(list->word->word), 0)
+      job = (list && legal_number (list->word->word, &value)
+            && value == (pid_t) value)
+               ? get_job_by_pid ((pid_t) value, 0)
                : get_job_spec (list);
 
       if (job == NO_JOB || jobs == 0 || job < 0 || job >= job_slots || 
jobs[job] == 0)
===================================================================
RCS file: builtins/kill.def,v
retrieving revision 2.5
retrieving revision 2.5.0.1
diff -pu -r2.5 -r2.5.0.1
--- builtins/kill.def   1999/08/05 11:43:12     2.5
+++ builtins/kill.def   2001/04/30 01:17:51     2.5.0.1
@@ -78,6 +78,7 @@ kill_builtin (list)
   int signal, any_succeeded, listing, saw_signal;
   char *sigspec, *word;
   pid_t pid;
+  long value;
 
   if (list == 0)
     {
@@ -164,10 +165,10 @@ kill_builtin (list)
       if (*word == '-')
        word++;
 
-      if (*word && all_digits (word))
+      /* Use the entire argument in case of minus sign presence.  */
+      if (legal_number (list->word->word, &value) && value == (pid_t) value)
        {
-         /* Use the entire argument in case of minus sign presence. */
-         pid = (pid_t) atoi (list->word->word);
+         pid = (pid_t) value;
 
          if (kill_pid (pid, signal, 0) < 0)
            goto signal_error;
===================================================================
RCS file: builtins/wait.def,v
retrieving revision 2.5
retrieving revision 2.5.0.1
diff -pu -r2.5 -r2.5.0.1
--- builtins/wait.def   2001/01/17 20:40:08     2.5
+++ builtins/wait.def   2001/04/30 01:17:51     2.5.0.1
@@ -120,13 +120,14 @@ wait_builtin (list)
     {
       pid_t pid;
       char *w;
+      long value;
 
       w = list->word->word;
       if (digit (*w))
        {
-         if (all_digits (w + 1))
+         if (legal_number (w, &value) && value == (pid_t) value)
            {
-             pid = (pid_t)atoi (w);
+             pid = (pid_t) value;
              status = wait_for_single_pid (pid);
            }
          else



reply via email to

[Prev in Thread] Current Thread [Next in Thread]