On Thu, 2006-10-05 at 17:48 +0200, Stefan Seyfried wrote:
> Hi,
> 
> i tested pm-utils and pm-suspend gave me the following:
> t8200:~ # pm-suspend
> /etc/pm/functions: line 3: /etc/rc.d/init.d/functions: No such file or 
> directory
> /etc/pm/functions: line 36: /usr/bin/fgconsole: No such file or directory
> /etc/pm/functions: line 3: /etc/rc.d/init.d/functions: No such file or 
> directory
> /etc/pm/functions: line 3: /etc/rc.d/init.d/functions: No such file or 
> directory
> /etc/pm/functions: line 3: /etc/rc.d/init.d/functions: No such file or 
> directory
> /etc/pm/functions: line 3: /etc/rc.d/init.d/functions: No such file or 
> directory
> /etc/pm/functions: line 3: /etc/rc.d/init.d/functions: No such file or 
> directory
> /etc/pm/functions: line 3: /etc/rc.d/init.d/functions: No such file or 
> directory
> /etc/pm/functions: line 3: /etc/rc.d/init.d/functions: No such file or 
> directory
> awk: { for (i=NF; i>=1; i--) if ($i !~ /~$/ { print $i } }
> awk:                                        ^ syntax error
> usage: chvt N
> t8200:~ #
> 
> so i am suggesting the following patches:
> Index: pm/functions
> ===================================================================
> RCS file: /cvs/pm-utils/pm-utils/pm/functions,v
> retrieving revision 1.20
> diff -u -p -r1.20 functions
> --- pm/functions      28 Sep 2006 21:25:36 -0000      1.20
> +++ pm/functions      5 Oct 2006 15:37:46 -0000
> @@ -1,6 +1,6 @@
>  #!/bin/bash
>  
> -. /etc/rc.d/init.d/functions
> +[ -e /etc/rc.d/init.d/functions ] && . /etc/rc.d/init.d/functions

Looks very sane.

>  # default values go here
>  HIBERNATE_RESUME_POST_VIDEO=no
> 
> -----------------
> It would be interesting what stuff actually is in /etc/rc.d/init.d/functions
> and what i will loose by not including it...
> 
> 
> Index: pm/functions
> ===================================================================
> RCS file: /cvs/pm-utils/pm-utils/pm/functions,v
> retrieving revision 1.20
> diff -u -p -r1.20 functions
> --- pm/functions      28 Sep 2006 21:25:36 -0000      1.20
> +++ pm/functions      5 Oct 2006 15:18:24 -0000
> @@ -62,9 +62,15 @@ run_hooks()
>       [ -f /var/run/pm-suspend ] && . /var/run/pm-suspend
>       rm -f /var/run/pm-suspend
>  
> -     files="/etc/pm/hooks/*"
> +     files="/etc/pm/hooks/*[^~]"
>       if [ "$2" = "reverse" ]; then
> -             files=$(echo $files | awk '{ for (i=NF; i>=1; i--) if ($i !~ 
> /~$/ { print $i } }')
> +             filea=($files)
> +             filen=${#filea[*]}
> +             files=""
> +             while [ $filen -gt 0 ]; do
> +                     let filen--
> +                     files="$files ${filea[$filen]}"
> +             done
>       fi
>       for file in $files ; do
>               [ -x $file ] && $file $1
> 
> -------
> (actually, the awk is just missing a ")" after "if ($i !~ /~$/) {...", but
> this "if" is totally unneeded by adjusting the glob pattern, and it probably
> is cheaper to reverse the files in bash than forking off awk, i did it in
> bash).

yes, this looks good too.

> Index: pm/functions
> ===================================================================
> RCS file: /cvs/pm-utils/pm-utils/pm/functions,v
> retrieving revision 1.20
> diff -u -p -r1.20 functions
> --- pm/functions      28 Sep 2006 21:25:36 -0000      1.20
> +++ pm/functions      5 Oct 2006 15:39:47 -0000
> @@ -33,10 +33,10 @@ source_configs
>  
>  take_suspend_lock()
>  {
> -     VT=$(/usr/bin/fgconsole)
> +     VT=$(PATH=/bin:/usr/bin fgconsole)
>       chvt 63
>       if [ -f /.suspended ]; then
> -             pid=$(cat /.suspended)
> +             read pid < /.suspended
>               if [ -d /proc/$pid ]; then
>                       return 1
>               fi

Yes, also this is good.

> ----------
> maybe we could also find fgconsole with configure and hardcode it depending
> on the distribution, might be faster than searching the two directories, but
> i am not too autofoo-savvy so i went the easy way. We should save this by
> avoiding forking off cat :-)

Hmm, I would trade an extra fork for not doing lots of configure-foo.

> I'll additionally attach the patches since i am not sure which way is the
> preferred one.

Peter, what say you? I'll cc you in case you too are not getting
messages from pm-utils m/l.

Richard.


_______________________________________________
Pm-utils mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/pm-utils

Reply via email to