#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Posts
    4
    Rep Power
    0

    problems with the sleep function...


    (in Linux)

    when i use the sleep function, it looks like it works, but rather strangly...

    so if i do:

    sleep(1);
    puts ("hello!!!");
    sleep(1);
    puts("hi!");

    it will freeze and when it unfreezes, it will display:

    hello!!!
    he!

    instantly, without the 1 secound pause that was supposed to be between them.

    thanks to every1 that will be kind enough to help...
  2. #2
  3. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,172
    Rep Power
    2222
    Your code worked fine for me on Red Hat 7.0.

    I assume that you are just running it straight from the command line and not redirecting or piping the output. For example, when I piped the output to more, I got the same behavior that you described. That would tell me that for some reason your output is getting buffered somewhere and isn't getting written to stdout until the program exits. Tell me, when you say that the system freezes, does it freeze for just about two seconds?
    Last edited by dwise1_aol; April 9th, 2003 at 02:11 PM.

IMN logo majestic logo threadwatch logo seochat tools logo