>>>>> "Y" == Yukihiro Matsumoto <matz / ruby-lang.org> writes:

Y>   usleep(10000);

nasun% man usleep
Reformatting page.  Please Wait... done

Standard C Library Functions                           usleep(3C)

NAME
     usleep - suspend execution for interval in microseconds
[...]
USAGE
     The usleep() function is included for its historical  usage.
     The setitimer(2) function is preferred over this function.

[...]
nasun% 

Y>   select(0, NULL, NULL, NULL, &tv);

 Well probably it must work (not really clear for me)

nasun% man -s 3c select
Reformatting page.  Please Wait... done

Standard C Library Functions                           select(3C)

NAME
     select, FD_SET, FD_CLR, FD_ISSET, FD_ZERO - synchronous  I/O
     multiplexing

[...]
     If the readfs, writefs, and errorfds arguments are all  null
     pointers  and  the  timeout  argument is not a null pointer,
     select() blocks for the time specified, or until interrupted
     by  a signal. If the readfs, writefs, and errorfds arguments
     are all null pointers and the timeout  argument  is  a  null
     pointer, select() blocks until interrupted by a signal.
[...]
nasun%

 actually I don't try to interrupt it because this is the first time that
 it can do this

nasun% ps
   PID TT       S  TIME COMMAND
 21336 pts/4    S  0:00 -bash
  9651 pts/27   S  0:00 -bash
 17326 pts/27   R 258:29 ruby s.rb
 21485 pts/27   S 11:16 ruby c.rb
nasun% 

nasun% pstack 17326
17326:  ruby s.rb
-----------------  lwp# 1 / thread# 1  --------------------
 ff3406e8 memcpy   (14e8330, 2, 0, ffbcde88, 71a400, 0) + e4
 0002bff8 stack_extend (14e8330, 2, 0, 0, 0, 0) + 18
 0002c180 rb_thread_restore_context (ca000, ca000, ca000, ffbcfaf0, d8b10c, 50dc) + 17c
-----------------  lwp# 2 / thread# 2  --------------------
 ff29edc0 signotifywait ()
 ff18e950 _dynamiclwps (ff1ac000, 0, 0, 0, 0, 0) + 1c
 ff191c2c thr_yield (0, 0, 0, 0, 0, 0) + 8c
-----------------  lwp# 3  --------------------------------
 ff29c964 door     (0, 0, 0, 0, ff175d38, 4)
 ff1967c8 _sc_door_func (0, 0, 0, 0, 0, 0) + 54
-----------------  lwp# 4 / thread# 4  --------------------
 ff29bde0 nanosleep (fee0bd20, fee0bd18)
 ff19a440 __nanosleep (0, ff0a3d38, 1, ff1b8d04, 0, 2) + 34
 ff19b01c _thread_start (0, 0, 0, 0, 0, 0) + 40
--------------------------  thread# 3  --------------------
 ff18d9b8 _reap_wait (ff1b0980, 1e924, 0, ff1ac000, 0, 0) + 38
 ff18d710 _reaper  (ff1ace00, ff1b2708, ff1b0980, ff1acdd8, 1, fe400000) + 38
 ff19b01c _thread_start (0, 0, 0, 0, 0, 0) + 40
nasun%
 
nasun% pstack 21485
21485:  ruby c.rb
-----------------  lwp# 1 / thread# 1  --------------------
 ff29f6e0 __setcontext (8d5f78, 437784, 13, 0, be000, 1) + 10
 0002c868 rb_thread_schedule (1, 227e7a8, 1, ffbd4ef0, ffbd4f70, ffbd4ff0) + 2f4
 0005dfa0 rb_f_sleep (ffbd50e0, ffbd5528, 1d9610, ffffffff, 2fc88, 2ffec) + 38
 0002ffdc call_cfunc (5df68, 1d9610, ffffffff, 1, ffbd5528, 0) + 3bc
 00024624 rb_call0 (107978, 1d9610, 22a9, ffffffff, 1, ffbd5528) + 2b4
 00024e3c rb_call  (f77f0, 1d9610, 22a9, 1, ffbd5528, 1) + 130
[...]
 0001bae8 ruby_exec (0, ffbefa84, 0, be034, be064, 0) + a0
 0001bb40 ruby_run (2, ffbefa84, 0, 0, 0, 0) + 20
 00019b48 main     (2, ffbefa84, ffbefa90, ccbfc, 0, 0) + 18
 000199c8 _start   (0, 0, 0, 0, 0, 0) + 5c
-----------------  lwp# 2 / thread# 2  --------------------
 ff29edc0 signotifywait ()
 ff18e950 _dynamiclwps (ff1ac000, 0, 0, 0, 0, 0) + 1c
 ff191c2c thr_yield (0, 0, 0, 0, 0, 0) + 8c
-----------------  lwp# 3  --------------------------------
 ff29c964 door     (0, 0, 0, 0, ff175d38, 4)
 ff1967c8 _sc_door_func (0, 0, 0, 0, 0, 0) + 54
-----------------  lwp# 4 / thread# 4  --------------------
 ff29bde0 nanosleep (fee0bd20, fee0bd18)
 ff19a440 __nanosleep (0, ff0f3d38, 1, ff1b8d04, 0, 2) + 34
 ff19b01c _thread_start (0, 0, 0, 0, 0, 0) + 40
-----------------  lwp# 5  --------------------------------
 ff1991fc lwp_cond_wait (ff1b34e8, ff1b34f8, ff1acd80)
 ff188cc4 _age     (3e, ff1acd6c, ff1ac000, 3, ff1ac000, 1) + 74
 ff18a358 _lwp_start (ff0e3d98, 0, 4000, ff00fc54, 0, 0) + 18
 ff191c2c thr_yield (0, 0, 0, 0, 0, 0) + 8c
--------------------------  thread# 3  --------------------
 ff18d9b8 _reap_wait (ff1b0980, 1e924, 0, ff1ac000, 0, 0) + 38
 ff18d710 _reaper  (ff1ace00, ff1b2708, ff1b0980, ff1acdd8, 1, fe400000) + 38
 ff19b01c _thread_start (0, 0, 0, 0, 0, 0) + 40
nasun% 


Guy Decoux