diff --git a/src/modules/system/system.c b/src/modules/system/system.c index c6418e1e29895bd7db083f91eed6559d3ef0ad89..c1220429835e3ac0c38720c8ebaa2f83286e6fcc 100644 --- a/src/modules/system/system.c +++ b/src/modules/system/system.c @@ -1,5 +1,5 @@ /* - * $Id: system.c,v 1.91 2000/09/17 19:13:54 grubba Exp $ + * $Id: system.c,v 1.92 2000/09/29 12:47:45 mirar Exp $ * * System-call module for Pike * @@ -15,7 +15,7 @@ #include "system_machine.h" #include "system.h" -RCSID("$Id: system.c,v 1.91 2000/09/17 19:13:54 grubba Exp $"); +RCSID("$Id: system.c,v 1.92 2000/09/29 12:47:45 mirar Exp $"); #ifdef HAVE_WINSOCK_H #include <winsock.h> #endif @@ -1398,7 +1398,6 @@ void f_gethostbyname(INT32 args) } #endif /* HAVE_GETHOSTBYNAME */ - #ifdef GETHOSTBYNAME_MUTEX_EXISTS static void cleanup_after_fork(struct callback *cb, void *arg0, void *arg1) { @@ -1408,6 +1407,23 @@ static void cleanup_after_fork(struct callback *cb, void *arg0, void *arg1) extern void init_passwd(void); + +#ifdef HAVE_SLEEP +/* int sleep(int seconds) */ + +static void f_system_sleep(INT32 args) +{ + INT_TYPE seconds; + get_all_args("setegid", args, "%i", &seconds); + if (seconds<0) seconds=0; /* sleep takes unsinged */ + pop_n_elems(args); + THREADS_ALLOW(); + seconds=(INT_TYPE)sleep( (unsigned int)seconds ); + THREADS_DISALLOW(); + push_int(seconds); +} +#endif /* HAVE_SLEEP */ + /* * Module linkage */ @@ -1648,6 +1664,8 @@ void pike_module_init(void) ADD_FUNCTION("closelog", f_closelog,tFunc(tNone,tVoid), 0); #endif /* HAVE_SYSLOG */ + ADD_FUNCTION("sleep",f_system_sleep,tFunc(tInt,tInt), 0); + init_passwd(); #ifdef GETHOSTBYNAME_MUTEX_EXISTS diff --git a/tutorial/tutorial.wmml b/tutorial/tutorial.wmml index 11b018f54d4c9f03673c717d2de30d70a57d5e64..8868c5647965b87d0fee613d2b32695c9344e670 100644 --- a/tutorial/tutorial.wmml +++ b/tutorial/tutorial.wmml @@ -6718,6 +6718,26 @@ the fchroot(2) system call. </function> +<function name=sleep title="call the system sleep(3)"> +<man_syntax> +int sleep(int seconds); +</man_syntax> +<man_description> +Calls the system sleep. This is not to be confused with the efun <link +to=sleep>sleep</link>(int|float) that does more elaborate things and +can sleep with better precision (although dependant on a normal +functioning system clock). +</man_description> +<man_note> +The system's sleep function often utilizes the alarm() call and might +not be perfectly thread safe in combination with simultaneous +sleep()'s or alarm()'s. It might also be interrupted by other signals. + +<p>If you don't need it to be independant of the system clock, use the +<link to=sleep>sleep</link>() efun instead. +</man_note> +</function> + <function name=getegid title="get the effective group ID" fullpath> <man_syntax>