comparison src/process.c @ 95387:be7d86474ead

(Faccept_process_output): If `millisec' is non-nil, `seconds' default to 0. (wait_reading_process_output): Also return non-nil if we read output from a non-running process.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Thu, 29 May 2008 16:54:53 +0000
parents ad146a8ff5dc
children d6a4488883dc
comparison
equal deleted inserted replaced
95386:9d7e990b655a 95387:be7d86474ead
3894 3894
3895 Non-nil second arg SECONDS and third arg MILLISEC are number of 3895 Non-nil second arg SECONDS and third arg MILLISEC are number of
3896 seconds and milliseconds to wait; return after that much time whether 3896 seconds and milliseconds to wait; return after that much time whether
3897 or not there is input. If SECONDS is a floating point number, 3897 or not there is input. If SECONDS is a floating point number,
3898 it specifies a fractional number of seconds to wait. 3898 it specifies a fractional number of seconds to wait.
3899 The MILLISEC argument is obsolete and should be avoided.
3899 3900
3900 If optional fourth arg JUST-THIS-ONE is non-nil, only accept output 3901 If optional fourth arg JUST-THIS-ONE is non-nil, only accept output
3901 from PROCESS, suspending reading output from other processes. 3902 from PROCESS, suspending reading output from other processes.
3902 If JUST-THIS-ONE is an integer, don't run any timers either. 3903 If JUST-THIS-ONE is an integer, don't run any timers either.
3903 Return non-nil if we received any output before the timeout expired. */) 3904 Return non-nil if we received any output before the timeout expired. */)
3909 if (! NILP (process)) 3910 if (! NILP (process))
3910 CHECK_PROCESS (process); 3911 CHECK_PROCESS (process);
3911 else 3912 else
3912 just_this_one = Qnil; 3913 just_this_one = Qnil;
3913 3914
3915 if (!NILP (millisec))
3916 { /* Obsolete calling convention using integers rather than floats. */
3917 CHECK_NUMBER (millisec);
3918 if (NILP (seconds))
3919 seconds = make_float (XINT (millisec) / 1000.0);
3920 else
3921 {
3922 CHECK_NUMBER (seconds);
3923 seconds = make_float (XINT (millisec) / 1000.0 + XINT (seconds));
3924 }
3925 }
3926
3914 if (!NILP (seconds)) 3927 if (!NILP (seconds))
3915 { 3928 {
3916 if (INTEGERP (seconds)) 3929 if (INTEGERP (seconds))
3917 secs = XINT (seconds); 3930 secs = XINT (seconds);
3918 else if (FLOATP (seconds)) 3931 else if (FLOATP (seconds))
3921 secs = (int) timeout; 3934 secs = (int) timeout;
3922 usecs = (int) ((timeout - (double) secs) * 1000000); 3935 usecs = (int) ((timeout - (double) secs) * 1000000);
3923 } 3936 }
3924 else 3937 else
3925 wrong_type_argument (Qnumberp, seconds); 3938 wrong_type_argument (Qnumberp, seconds);
3926
3927 if (INTEGERP (millisec))
3928 {
3929 int carry;
3930 usecs += XINT (millisec) * 1000;
3931 carry = usecs / 1000000;
3932 secs += carry;
3933 if ((usecs -= carry * 1000000) < 0)
3934 {
3935 secs--;
3936 usecs += 1000000;
3937 }
3938 }
3939 3939
3940 if (secs < 0 || (secs == 0 && usecs == 0)) 3940 if (secs < 0 || (secs == 0 && usecs == 0))
3941 secs = -1, usecs = 0; 3941 secs = -1, usecs = 0;
3942 } 3942 }
3943 else 3943 else
4473 4473
4474 if (nread == 0) 4474 if (nread == 0)
4475 break; 4475 break;
4476 4476
4477 if (0 < nread) 4477 if (0 < nread)
4478 total_nread += nread; 4478 {
4479 total_nread += nread;
4480 got_some_input = 1;
4481 }
4479 #ifdef EIO 4482 #ifdef EIO
4480 else if (nread == -1 && EIO == errno) 4483 else if (nread == -1 && EIO == errno)
4481 break; 4484 break;
4482 #endif 4485 #endif
4483 #ifdef EAGAIN 4486 #ifdef EAGAIN