11876 Want a native sleep

Review Request #2417 — Created Oct. 25, 2019 and submitted

rm
illumos-gate
master
11876
cf0ee79...
general
11876 Want a native sleep


  • 0
  • 0
  • 12
  • 1
  • 13
Description From Last Updated
yuripv
  1. 
      
  2. usr/src/man/man1/sleep.1 (Diff revision 1)
     
     

    This doesn't match the usage in the program itself.

  3. usr/src/man/man1/sleep.1 (Diff revision 1)
     
     

    terminate

  4. usr/src/man/man1/sleep.1 (Diff revision 1)
     
     

    I'd strip the roff codes here, they don't help anything.

  5. usr/src/man/man1/sleep.1 (Diff revision 1)
     
     

    I don't think LC_MESSAGES and NLSPATH affect anything as you don't seem to use gettext()?

    1. OK. I guess that's true. Should I go back and use gettext()? Or wait until someone has translations?

    2. Use gettext() now. Then someone can add the translations without touching the code. i18n should always be done first, l10n can occur later, or even never.

    3. OK, the most recent revision has this.

  6. usr/src/man/man1/sleep.1 (Diff revision 1)
     
     

    Why? I don't think linking to library functions is helpful here.

    1. It's something we've done in other manual pages. I think knowing what library functions can be used to do the same thing is useful and helps one understand it.

    2. I agree with Robert on this one.

  7. Don't need this target?

  8. 
      
hans
  1. 
      
  2. usr/src/cmd/sleep/sleep.c (Diff revision 1)
     
     
    nit: Since you're really using strtold() further down, perhaps use that in the comment too instead of strtod()?
  3. usr/src/man/man1/sleep.1 (Diff revision 1)
     
     

    spelling: least

  4. 
      
gdamore
  1. Ship It!
  2. 
      
marcel
  1. 
      
  2. usr/src/man/man1/sleep.1 (Diff revision 1)
     
     

    BSIGALARM?

  3. 
      
marcel
  1. 
      
  2. usr/src/cmd/sleep/sleep.c (Diff revision 1)
     
     

    Shouldn't this read "sleep time[suffix]" instead?

  3. usr/src/cmd/sleep/sleep.c (Diff revision 1)
     
     

    I suggest to add || eptr == argv[1] here to cover two cases:

    1) sleep s will properly report "failed to parse time s" instead of silently succeed.
    2) sleep "", so you could remove the explicit test for this case above.

    1. Thanks, that's a good suggestion.

  4. usr/src/cmd/sleep/sleep.c (Diff revision 1)
     
     

    We should fail for sec < 0 (man page says: non-negative). We should also fail for cases like sleep -0.2.

    1. There were several other issues parsing some of this, which I've gone and fixed up here, thanks.

  5. usr/src/man/man1/sleep.1 (Diff revision 1)
     
     

    hours, not minutes

  6. 
      
ptribble
  1. 
      
  2. usr/src/cmd/sleep/Makefile (Diff revision 1)
     
     

    lint is no more

  3. infinity, not infinite

  4. 
      
rm
rm
hans
  1. Ship It!
  2. 
      
marcel
  1. 
      
  2. usr/src/cmd/sleep/sleep.c (Diff revision 3)
     
     

    Please test what does:

    sleep " "
    sleep " s"
    sleep " -s"
    sleep " +s"
    sleep "1 "

    I suspect at least some of them won't work as expected.

    There is also general question: Should sleep " 1" succeed or fail? It looks like both GNU sleep and ksh sleep succeeds here.

    Also, it looks like /usr/bin/sleep "1 " (ksh sleep) sleeps forever, while /usr/gnu/bin/sleep "1 " (GNU sleep) simply fails.

    1. All of the ones that you have there properly fail:

      rm@turin:/ws/rm/sleep/usr/src/cmd/sleep$ ./sleep " "
      sleep: failed to parse time ' '
      rm@turin:/ws/rm/sleep/usr/src/cmd/sleep$ ./sleep " s"
      sleep: failed to parse time ' s'
      rm@turin:/ws/rm/sleep/usr/src/cmd/sleep$ ./sleep " -s"
      sleep: failed to parse time ' -s'
      rm@turin:/ws/rm/sleep/usr/src/cmd/sleep$ ./sleep " +s"
      sleep: failed to parse time ' +s'
      rm@turin:/ws/rm/sleep/usr/src/cmd/sleep$ ./sleep "1 "
      sleep: failed to parse time 1 
      

      sleep " 1" does suceeed like ksh and GNU. I can add these to the test suite, but can you be more explicit about what your concern is? It seems like you suspect something is broken in the line of code highlighted.

    2. Okay, thanks for tests.

      I somehow expected that with " s" the strtold() will set eptr to point to 's', not to leading ' '. But this expectation was wrong, apparently (even the strtold(3c) man page specifies that).

  3. 
      
marcel
  1. 
      
  2. usr/src/cmd/sleep/sleep.c (Diff revision 3)
     
     

    At line 103 you compare with 0.0 when you want to compare with zero. I think these constants should be unified.

  3. 
      
marcel
  1. Ship It!
  2. 
      
rm
marcel
  1. Ship It!
  2. 
      
hans
  1. Ship It!
  2. 
      
rm
Review request changed

Status: Closed (submitted)

Loading...