Possible bug in /usr/bin/script? (was A Sleeping FreeBSD Box (again).)

nicky nicky at valuecare.nl
Fri Nov 10 08:09:04 UTC 2006



nicky wrote:
> Hello,
>
> This morning i had another 'sleeping' 6-stable box. I don't really 
> understand why it sleeps. I've checked acpi, but i doubt that is it. 
> Since at the time when it goes to sleep, it does some heavy 
> processing. I don't think it would choose to go to sleep then. The 
> most funny thing is, when you go to the console. You press Enter, just 
> Enter, you don't login, just punch the Enter button and the box 
> continues where it stopped. I typed in 'top' as soon as i could, which 
> showed the table below.
>
> The script commands capture the output of some shells scripts.
>
> last pid: 59391;  load averages: 13.19,  4.43,  
> 2.70                                     up 14+17:21:56  08:43:04
> 93 processes:  15 running, 78 sleeping
> CPU states:  5.7% user,  0.0% nice, 44.3% system,  0.0% interrupt, 
> 50.0% idle
> Mem: 433M Active, 1577M Inact, 194M Wired, 158M Cache, 112M Buf, 644M 
> Free
> Swap: 8192M Total, 320K Used, 8192M Free
>
>  PID USERNAME  THR PRI NICE   SIZE    RES STATE  C   TIME   WCPU COMMAND
> 58989 root        1 127    0  1340K   764K RUN    0 504:42 38561.75% 
> script
> 58986 root        1 127    0  1340K   764K RUN    0 504:41 38547.86% 
> script
> 58988 root        1 131    0  1340K   764K RUN    0   1:07 438.67% script
> 58990 root        1 131    0  1340K   764K RUN    2   0:43 337.69% script
> 58987 root        1 126    0  1340K   764K RUN    2   0:50 249.75% script
>
>
> Is it safe for me to assume that something is hogging my cpu, not 
> allowing any other processes to get some cpu time? As a result the box 
> does not respond to anything, like pinging?
>
> Or does top has a weird way of showing the cpu times when it has been 
> sleeping?
>
> While i still find it rather weird, that pressing Enter seems to solve 
> it.
>
> I hope someone can send some advice or hints my way.
>
> Regards,
> Nick
>
>
>
>
>

While trying to find out what is eating my CPU and probably making my 
box sleep. I've found something weird with /usr/bin/script.

Assume the following small sh script called sleep.sh.

#!/bin/sh

while [ 1 ]; do

        sleep 3
        echo "slept"

done

I'm executing the following: script outputfile ./sleep.sh

Executed from a terminal window, all is as i would have expected. No CPU 
hogging and doing like it should.
However if i execute it from cron, my CPU is used to the full 100%.

Is this a bug and should i report it?

Regards,
Nick




More information about the freebsd-questions mailing list