an alternative to fuser in progress_bar.sh

George Boudreau georgeb at linuxfromscratch.org
Wed Jun 28 15:06:10 PDT 2006


Dan,

   This may be an inexpensive (read 'cheap') replacement for the fuser 
fuser function . Could you try this on your machine and see what cpu cost is

   ..Logic.. ( possibly flawed)
*  'Make' must be run from the root account or via sudo so access to the 
/proc directory is not an issue.

*  We pick up the pid of the 'make' process whenever we kick start the 
timer bar but from then on we only use the 'pid' for the process status 
lookup.

  George

...inside progress_bar.sh

  # note.. DO NOT try and trace the variable makePID..
  # it changes the fuser text
makePID=$(fuser -v . 2>&1 | grep make)
makePID=$(echo $makePID | cut -d" " -f2)

write_or_exit() {

     # make has been killed or failed or run to completion, leave
   [[ ! -e /proc/$makePID ]] && echo -n "${CURSOR_ON}" && exit

     # Target build complete, leave.
   [[ -f ${TARGET} ]] && echo -n "${CURSOR_ON}" && exit

     # It is safe to write to the screen
   echo -n "$1"
}





More information about the alfs-discuss mailing list