Why_is_the_system_load_200
03 Jan 2007title: Why is the system load 200? date: Wed Jan 3 20:33:51 PST 2007 Tag: scripting
Here's a fun game: create a large (>1GB) file in your home directory called core and start Firefox. Have a look at this part of run-mozilla.sh:
if [ -x "$crc_prog" ] then ``` DEBUG_CORE_FILES=1 ``` fi if [ "$DEBUG_CORE_FILES" ] then ``` crc_old= if [ -f core ] then crc_old=`$crc_prog core | awk '{print $1;}' ` fi ``` fi ## ## Run the program ## "$prog" ${1+"$@"} exitcode=$? if [ "$DEBUG_CORE_FILES" ] then ``` if [ -f core ] then crc_new=`$crc_prog core | awk '{print $1;}' ` fi ``` fi if [ "$crc_old" != "$crc_new" ] then ``` printf "\n\nOh no! %s just dumped a core file.\n\n" $prog printf "Do you want to debug this ? " printf "You need a lot of memory for this, so watch out ? [y/n] \"
Care to guess what'll happen? That's right: Firefox will take 10
seconds to start up because its busy md5summing a big-ass core
file. The user will think that it hasn't launched at all and will
click again. Rinse and repeat, with more and more clicking every
time. By the time I figured out what was going wrong, the system load
was about 200. Fortunately, its a simple thing to add
DEBUG_CORE_FILES=
judiciously (not DEBUG_CORE_FILES=0
; I keep
forgetting that a simple [ $FOO ]
simply tests whether $FOO
is
empty, not whether its non-zero).
Also: the advantage to being in a small shop is that if youre the only one running Linux on the desktop, you can just go ahead and add things like the latest version of Firefox (now without the amusing bug that makes a search work on some other random tab, instead of the one you're looking at) and the MySQL DBD connector for Perl. It's really incredible how much irritation those two things are gonna save me.
Finally: this is just plain cool. As he did during the Bash scripting BOF,Wout takes me to school. Didn't know about: ssh -t, COLUMNS/LINES environment variables, tput, or just how much Applescript can do.
Add a comment:
Name and email required; email is not displayed.
Related Posts
QRP weekend 08 Oct 2018
Open Source Cubesat Workshop 2018 03 Oct 2018
mpd crash? try removing files in /var/lib/mpd/ 11 Aug 2018