diff options
Diffstat (limited to 'src/sysdep.c')
| -rw-r--r-- | src/sysdep.c | 68 |
1 files changed, 41 insertions, 27 deletions
diff --git a/src/sysdep.c b/src/sysdep.c index f97a8585253..ba296a2d094 100644 --- a/src/sysdep.c +++ b/src/sysdep.c | |||
| @@ -296,7 +296,7 @@ int wait_debugging EXTERNALLY_VISIBLE; | |||
| 296 | #ifndef MSDOS | 296 | #ifndef MSDOS |
| 297 | 297 | ||
| 298 | static void | 298 | static void |
| 299 | wait_for_termination_1 (int pid, int interruptible) | 299 | wait_for_termination_1 (pid_t pid, int interruptible) |
| 300 | { | 300 | { |
| 301 | while (1) | 301 | while (1) |
| 302 | { | 302 | { |
| @@ -344,14 +344,14 @@ wait_for_termination_1 (int pid, int interruptible) | |||
| 344 | make sure it will get eliminated (not remain forever as a zombie) */ | 344 | make sure it will get eliminated (not remain forever as a zombie) */ |
| 345 | 345 | ||
| 346 | void | 346 | void |
| 347 | wait_for_termination (int pid) | 347 | wait_for_termination (pid_t pid) |
| 348 | { | 348 | { |
| 349 | wait_for_termination_1 (pid, 0); | 349 | wait_for_termination_1 (pid, 0); |
| 350 | } | 350 | } |
| 351 | 351 | ||
| 352 | /* Like the above, but allow keyboard interruption. */ | 352 | /* Like the above, but allow keyboard interruption. */ |
| 353 | void | 353 | void |
| 354 | interruptible_wait_for_termination (int pid) | 354 | interruptible_wait_for_termination (pid_t pid) |
| 355 | { | 355 | { |
| 356 | wait_for_termination_1 (pid, 1); | 356 | wait_for_termination_1 (pid, 1); |
| 357 | } | 357 | } |
| @@ -1895,8 +1895,8 @@ emacs_close (int fd) | |||
| 1895 | /* Read from FILEDESC to a buffer BUF with size NBYTE, retrying if interrupted. | 1895 | /* Read from FILEDESC to a buffer BUF with size NBYTE, retrying if interrupted. |
| 1896 | Return the number of bytes read, which might be less than NBYTE. | 1896 | Return the number of bytes read, which might be less than NBYTE. |
| 1897 | On error, set errno and return -1. */ | 1897 | On error, set errno and return -1. */ |
| 1898 | EMACS_INT | 1898 | ptrdiff_t |
| 1899 | emacs_read (int fildes, char *buf, EMACS_INT nbyte) | 1899 | emacs_read (int fildes, char *buf, ptrdiff_t nbyte) |
| 1900 | { | 1900 | { |
| 1901 | register ssize_t rtnval; | 1901 | register ssize_t rtnval; |
| 1902 | 1902 | ||
| @@ -1912,11 +1912,11 @@ emacs_read (int fildes, char *buf, EMACS_INT nbyte) | |||
| 1912 | /* Write to FILEDES from a buffer BUF with size NBYTE, retrying if interrupted | 1912 | /* Write to FILEDES from a buffer BUF with size NBYTE, retrying if interrupted |
| 1913 | or if a partial write occurs. Return the number of bytes written, setting | 1913 | or if a partial write occurs. Return the number of bytes written, setting |
| 1914 | errno if this is less than NBYTE. */ | 1914 | errno if this is less than NBYTE. */ |
| 1915 | EMACS_INT | 1915 | ptrdiff_t |
| 1916 | emacs_write (int fildes, const char *buf, EMACS_INT nbyte) | 1916 | emacs_write (int fildes, const char *buf, ptrdiff_t nbyte) |
| 1917 | { | 1917 | { |
| 1918 | ssize_t rtnval; | 1918 | ssize_t rtnval; |
| 1919 | EMACS_INT bytes_written; | 1919 | ptrdiff_t bytes_written; |
| 1920 | 1920 | ||
| 1921 | bytes_written = 0; | 1921 | bytes_written = 0; |
| 1922 | 1922 | ||
| @@ -2151,7 +2151,8 @@ set_file_times (const char *filename, EMACS_TIME atime, EMACS_TIME mtime) | |||
| 2151 | int | 2151 | int |
| 2152 | mkdir (char *dpath, int dmode) | 2152 | mkdir (char *dpath, int dmode) |
| 2153 | { | 2153 | { |
| 2154 | int cpid, status, fd; | 2154 | pid_t cpid; |
| 2155 | int status, fd; | ||
| 2155 | struct stat statbuf; | 2156 | struct stat statbuf; |
| 2156 | 2157 | ||
| 2157 | if (stat (dpath, &statbuf) == 0) | 2158 | if (stat (dpath, &statbuf) == 0) |
| @@ -2681,7 +2682,10 @@ system_process_attributes (Lisp_Object pid) | |||
| 2681 | char *cmdline = NULL; | 2682 | char *cmdline = NULL; |
| 2682 | ptrdiff_t cmdsize = 0, cmdline_size; | 2683 | ptrdiff_t cmdsize = 0, cmdline_size; |
| 2683 | unsigned char c; | 2684 | unsigned char c; |
| 2684 | int proc_id, ppid, uid, gid, pgrp, sess, tty, tpgid, thcount; | 2685 | printmax_t proc_id; |
| 2686 | int ppid, pgrp, sess, tty, tpgid, thcount; | ||
| 2687 | uid_t uid; | ||
| 2688 | gid_t gid; | ||
| 2685 | unsigned long long u_time, s_time, cutime, cstime, start; | 2689 | unsigned long long u_time, s_time, cutime, cstime, start; |
| 2686 | long priority, niceness, rss; | 2690 | long priority, niceness, rss; |
| 2687 | unsigned long minflt, majflt, cminflt, cmajflt, vsize; | 2691 | unsigned long minflt, majflt, cminflt, cmajflt, vsize; |
| @@ -2692,11 +2696,18 @@ system_process_attributes (Lisp_Object pid) | |||
| 2692 | Lisp_Object attrs = Qnil; | 2696 | Lisp_Object attrs = Qnil; |
| 2693 | Lisp_Object cmd_str, decoded_cmd, tem; | 2697 | Lisp_Object cmd_str, decoded_cmd, tem; |
| 2694 | struct gcpro gcpro1, gcpro2; | 2698 | struct gcpro gcpro1, gcpro2; |
| 2695 | EMACS_INT uid_eint, gid_eint; | ||
| 2696 | 2699 | ||
| 2697 | CHECK_NUMBER_OR_FLOAT (pid); | 2700 | CHECK_NUMBER_OR_FLOAT (pid); |
| 2698 | proc_id = FLOATP (pid) ? XFLOAT_DATA (pid) : XINT (pid); | 2701 | if (FLOATP (pid)) |
| 2699 | sprintf (procfn, "/proc/%u", proc_id); | 2702 | { |
| 2703 | double v = XFLOAT_DATA (pid); | ||
| 2704 | if (! (TYPE_MINIMUM (pid_t) <= v && v < TYPE_MAXIMUM (pid_t) + 1.0)) | ||
| 2705 | return attrs; | ||
| 2706 | proc_id = v; | ||
| 2707 | } | ||
| 2708 | else | ||
| 2709 | proc_id = XINT (pid); | ||
| 2710 | sprintf (procfn, "/proc/%"pMd, proc_id); | ||
| 2700 | if (stat (procfn, &st) < 0) | 2711 | if (stat (procfn, &st) < 0) |
| 2701 | return attrs; | 2712 | return attrs; |
| 2702 | 2713 | ||
| @@ -2704,9 +2715,7 @@ system_process_attributes (Lisp_Object pid) | |||
| 2704 | 2715 | ||
| 2705 | /* euid egid */ | 2716 | /* euid egid */ |
| 2706 | uid = st.st_uid; | 2717 | uid = st.st_uid; |
| 2707 | /* Use of EMACS_INT stops GCC whining about limited range of data type. */ | 2718 | attrs = Fcons (Fcons (Qeuid, make_fixnum_or_float (uid)), attrs); |
| 2708 | uid_eint = uid; | ||
| 2709 | attrs = Fcons (Fcons (Qeuid, make_fixnum_or_float (uid_eint)), attrs); | ||
| 2710 | BLOCK_INPUT; | 2719 | BLOCK_INPUT; |
| 2711 | pw = getpwuid (uid); | 2720 | pw = getpwuid (uid); |
| 2712 | UNBLOCK_INPUT; | 2721 | UNBLOCK_INPUT; |
| @@ -2714,8 +2723,7 @@ system_process_attributes (Lisp_Object pid) | |||
| 2714 | attrs = Fcons (Fcons (Quser, build_string (pw->pw_name)), attrs); | 2723 | attrs = Fcons (Fcons (Quser, build_string (pw->pw_name)), attrs); |
| 2715 | 2724 | ||
| 2716 | gid = st.st_gid; | 2725 | gid = st.st_gid; |
| 2717 | gid_eint = gid; | 2726 | attrs = Fcons (Fcons (Qegid, make_fixnum_or_float (gid)), attrs); |
| 2718 | attrs = Fcons (Fcons (Qegid, make_fixnum_or_float (gid_eint)), attrs); | ||
| 2719 | BLOCK_INPUT; | 2727 | BLOCK_INPUT; |
| 2720 | gr = getgrgid (gid); | 2728 | gr = getgrgid (gid); |
| 2721 | UNBLOCK_INPUT; | 2729 | UNBLOCK_INPUT; |
| @@ -2955,15 +2963,24 @@ system_process_attributes (Lisp_Object pid) | |||
| 2955 | struct psinfo pinfo; | 2963 | struct psinfo pinfo; |
| 2956 | int fd; | 2964 | int fd; |
| 2957 | ssize_t nread; | 2965 | ssize_t nread; |
| 2958 | int proc_id, uid, gid; | 2966 | printmax_t proc_id; |
| 2967 | uid_t uid; | ||
| 2968 | gid_t gid; | ||
| 2959 | Lisp_Object attrs = Qnil; | 2969 | Lisp_Object attrs = Qnil; |
| 2960 | Lisp_Object decoded_cmd, tem; | 2970 | Lisp_Object decoded_cmd, tem; |
| 2961 | struct gcpro gcpro1, gcpro2; | 2971 | struct gcpro gcpro1, gcpro2; |
| 2962 | EMACS_INT uid_eint, gid_eint; | ||
| 2963 | 2972 | ||
| 2964 | CHECK_NUMBER_OR_FLOAT (pid); | 2973 | CHECK_NUMBER_OR_FLOAT (pid); |
| 2965 | proc_id = FLOATP (pid) ? XFLOAT_DATA (pid) : XINT (pid); | 2974 | if (FLOATP (pid)) |
| 2966 | sprintf (procfn, "/proc/%u", proc_id); | 2975 | { |
| 2976 | double v = XFLOAT_DATA (pid); | ||
| 2977 | if (! (TYPE_MINIMUM (pid_t) <= v && v < TYPE_MAXIMUM (pid_t) + 1.0)) | ||
| 2978 | return attrs; | ||
| 2979 | proc_id = v; | ||
| 2980 | } | ||
| 2981 | else | ||
| 2982 | proc_id = XINT (v); | ||
| 2983 | sprintf (procfn, "/proc/%"pMd, proc_id); | ||
| 2967 | if (stat (procfn, &st) < 0) | 2984 | if (stat (procfn, &st) < 0) |
| 2968 | return attrs; | 2985 | return attrs; |
| 2969 | 2986 | ||
| @@ -2971,9 +2988,7 @@ system_process_attributes (Lisp_Object pid) | |||
| 2971 | 2988 | ||
| 2972 | /* euid egid */ | 2989 | /* euid egid */ |
| 2973 | uid = st.st_uid; | 2990 | uid = st.st_uid; |
| 2974 | /* Use of EMACS_INT stops GCC whining about limited range of data type. */ | 2991 | attrs = Fcons (Fcons (Qeuid, make_fixnum_or_float (uid)), attrs); |
| 2975 | uid_eint = uid; | ||
| 2976 | attrs = Fcons (Fcons (Qeuid, make_fixnum_or_float (uid_eint)), attrs); | ||
| 2977 | BLOCK_INPUT; | 2992 | BLOCK_INPUT; |
| 2978 | pw = getpwuid (uid); | 2993 | pw = getpwuid (uid); |
| 2979 | UNBLOCK_INPUT; | 2994 | UNBLOCK_INPUT; |
| @@ -2981,8 +2996,7 @@ system_process_attributes (Lisp_Object pid) | |||
| 2981 | attrs = Fcons (Fcons (Quser, build_string (pw->pw_name)), attrs); | 2996 | attrs = Fcons (Fcons (Quser, build_string (pw->pw_name)), attrs); |
| 2982 | 2997 | ||
| 2983 | gid = st.st_gid; | 2998 | gid = st.st_gid; |
| 2984 | gid_eint = gid; | 2999 | attrs = Fcons (Fcons (Qegid, make_fixnum_or_float (gid)), attrs); |
| 2985 | attrs = Fcons (Fcons (Qegid, make_fixnum_or_float (gid_eint)), attrs); | ||
| 2986 | BLOCK_INPUT; | 3000 | BLOCK_INPUT; |
| 2987 | gr = getgrgid (gid); | 3001 | gr = getgrgid (gid); |
| 2988 | UNBLOCK_INPUT; | 3002 | UNBLOCK_INPUT; |