@@ -966,16 +966,18 @@ Returns a struct_siginfo containing information about the signal.");
966966static PyObject *
967967signal_sigtimedwait (PyObject * self , PyObject * args )
968968{
969- PyObject * signals ;
970- double timeout , frac ;
969+ PyObject * signals , * timeout_obj ;
971970 struct timespec ts ;
972971 sigset_t set ;
973972 siginfo_t si ;
974973 int res ;
975- _PyTime_timeval deadline , monotonic ;
974+ _PyTime_t timeout , deadline , monotonic ;
975+
976+ if (!PyArg_ParseTuple (args , "OO:sigtimedwait" ,
977+ & signals , & timeout_obj ))
978+ return NULL ;
976979
977- if (!PyArg_ParseTuple (args , "Od:sigtimedwait" ,
978- & signals , & timeout ))
980+ if (_PyTime_FromSecondsObject (& timeout , timeout_obj , _PyTime_ROUND_UP ) < 0 )
979981 return NULL ;
980982
981983 if (timeout < 0 ) {
@@ -986,14 +988,11 @@ signal_sigtimedwait(PyObject *self, PyObject *args)
986988 if (iterable_to_sigset (signals , & set ))
987989 return NULL ;
988990
989- _PyTime_monotonic (& deadline );
990- _PyTime_AddDouble (& deadline , timeout , _PyTime_ROUND_UP );
991+ deadline = _PyTime_GetMonotonicClock () + timeout ;
991992
992993 do {
993- frac = fmod (timeout , 1.0 );
994- timeout = floor (timeout );
995- ts .tv_sec = (long )timeout ;
996- ts .tv_nsec = (long )(frac * 1e9 );
994+ if (_PyTime_AsTimespec (timeout , & ts ) < 0 )
995+ return NULL ;
997996
998997 Py_BEGIN_ALLOW_THREADS
999998 res = sigtimedwait (& set , & si , & ts );
@@ -1013,9 +1012,9 @@ signal_sigtimedwait(PyObject *self, PyObject *args)
10131012 if (PyErr_CheckSignals ())
10141013 return NULL ;
10151014
1016- _PyTime_monotonic ( & monotonic );
1017- timeout = _PyTime_INTERVAL ( monotonic , deadline ) ;
1018- if (timeout <= 0.0 )
1015+ monotonic = _PyTime_GetMonotonicClock ( );
1016+ timeout = deadline - monotonic ;
1017+ if (timeout <= 0 )
10191018 break ;
10201019 } while (1 );
10211020
0 commit comments