aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c74
1 files changed, 36 insertions, 38 deletions
diff --git a/src/process.c b/src/process.c
index a82932ba57b..e3fa187565f 100644
--- a/src/process.c
+++ b/src/process.c
@@ -3843,62 +3843,60 @@ DEFUN ("accept-process-output", Faccept_process_output, Saccept_process_output,
3843It is read into the process' buffers or given to their filter functions. 3843It is read into the process' buffers or given to their filter functions.
3844Non-nil arg PROCESS means do not return until some output has been received 3844Non-nil arg PROCESS means do not return until some output has been received
3845from PROCESS. 3845from PROCESS.
3846Non-nil second arg TIMEOUT and third arg TIMEOUT-MSECS are number of 3846
3847seconds and microseconds to wait; return after that much time whether 3847Non-nil second arg SECONDS and third arg MILLISEC are number of
3848or not there is input. 3848seconds and milliseconds to wait; return after that much time whether
3849or not there is input. If SECONDS is a floating point number,
3850it specifies a fractional number of seconds to wait.
3851
3849If optional fourth arg JUST-THIS-ONE is non-nil, only accept output 3852If optional fourth arg JUST-THIS-ONE is non-nil, only accept output
3850from PROCESS, suspending reading output from other processes. 3853from PROCESS, suspending reading output from other processes.
3851If JUST-THIS-ONE is an integer, don't run any timers either. 3854If JUST-THIS-ONE is an integer, don't run any timers either.
3852Return non-nil iff we received any output before the timeout expired. */) 3855Return non-nil iff we received any output before the timeout expired. */)
3853 (process, timeout, timeout_msecs, just_this_one) 3856 (process, seconds, millisec, just_this_one)
3854 register Lisp_Object process, timeout, timeout_msecs, just_this_one; 3857 register Lisp_Object process, seconds, millisec, just_this_one;
3855{ 3858{
3856 int seconds; 3859 int secs, usecs = 0;
3857 int useconds;
3858 3860
3859 if (! NILP (process)) 3861 if (! NILP (process))
3860 CHECK_PROCESS (process); 3862 CHECK_PROCESS (process);
3861 else 3863 else
3862 just_this_one = Qnil; 3864 just_this_one = Qnil;
3863 3865
3864 if (! NILP (timeout_msecs)) 3866 if (!NILP (seconds))
3865 { 3867 {
3866 CHECK_NUMBER (timeout_msecs); 3868 if (INTEGERP (seconds))
3867 useconds = XINT (timeout_msecs); 3869 secs = XINT (seconds);
3868 if (!INTEGERP (timeout)) 3870 else if (FLOATP (seconds))
3869 XSETINT (timeout, 0); 3871 {
3870 3872 double timeout = XFLOAT_DATA (seconds);
3871 { 3873 secs = (int) timeout;
3872 int carry = useconds / 1000000; 3874 usecs = (int) ((timeout - (double) secs) * 1000000);
3873 3875 }
3874 XSETINT (timeout, XINT (timeout) + carry); 3876 else
3875 useconds -= carry * 1000000; 3877 wrong_type_argument (Qnumberp, seconds);
3876 3878
3877 /* I think this clause is necessary because C doesn't 3879 if (INTEGERP (millisec))
3878 guarantee a particular rounding direction for negative 3880 {
3879 integers. */ 3881 int carry;
3880 if (useconds < 0) 3882 usecs += XINT (millisec) * 1000;
3881 { 3883 carry = usecs / 1000000;
3882 XSETINT (timeout, XINT (timeout) - 1); 3884 secs += carry;
3883 useconds += 1000000; 3885 if ((usecs -= carry * 1000000) < 0)
3884 } 3886 {
3885 } 3887 secs--;
3886 } 3888 usecs += 1000000;
3887 else 3889 }
3888 useconds = 0; 3890 }
3889 3891
3890 if (! NILP (timeout)) 3892 if (secs < 0 || (secs == 0 && usecs == 0))
3891 { 3893 secs = -1, usecs = 0;
3892 CHECK_NUMBER (timeout);
3893 seconds = XINT (timeout);
3894 if (seconds < 0 || (seconds == 0 && useconds == 0))
3895 seconds = -1;
3896 } 3894 }
3897 else 3895 else
3898 seconds = NILP (process) ? -1 : 0; 3896 secs = NILP (process) ? -1 : 0;
3899 3897
3900 return 3898 return
3901 (wait_reading_process_output (seconds, useconds, 0, 0, 3899 (wait_reading_process_output (secs, usecs, 0, 0,
3902 Qnil, 3900 Qnil,
3903 !NILP (process) ? XPROCESS (process) : NULL, 3901 !NILP (process) ? XPROCESS (process) : NULL,
3904 NILP (just_this_one) ? 0 : 3902 NILP (just_this_one) ? 0 :