All of lore.kernel.org
 help / color / mirror / Atom feed
From: Darren Hart <dvhart@linux.intel.com>
To: Robert Yang <liezhi.yang@windriver.com>
Cc: poky@yoctoproject.org
Subject: Re: V3 [PATCH 3/4] Add pidofproc to ${sysconfdir}/init.d/functions
Date: Mon, 16 May 2011 22:22:41 -0700	[thread overview]
Message-ID: <4DD20621.6080305@linux.intel.com> (raw)
In-Reply-To: <64381f0d88c840c6cb48392c1094b87149ed5372.1305599686.git.liezhi.yang@windriver.com>



On 05/16/2011 07:40 PM, Robert Yang wrote:
> Add pidofproc to ${sysconfdir}/init.d/functions, this is used for
> getting the pid of the process. It uses pidof to implement currently, it
> may also use the pidfile or ps to implement in the future.
> 
> Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
> ---
>  .../initscripts/initscripts-1.0/functions          |   32 ++++++++++++++++++-
>  1 files changed, 30 insertions(+), 2 deletions(-)
> 
> diff --git a/meta/recipes-core/initscripts/initscripts-1.0/functions b/meta/recipes-core/initscripts/initscripts-1.0/functions
> index ac99e11..1c8e5ce 100644
> --- a/meta/recipes-core/initscripts/initscripts-1.0/functions
> +++ b/meta/recipes-core/initscripts/initscripts-1.0/functions
> @@ -3,6 +3,35 @@
>  # functions     This file contains functions to be used by most or all
>  #               shell scripts in the /etc/init.d directory.
>  #
> +# NOTE: The pidofproc () doesn't support the process which is a script unless
> +#       the pidof supports "-x" option. If you want to use it for such a
> +#       process:
> +#       1) If there is no "pidof -x", replace the "pidof $1" with another
> +#          command like(for core-image-minimal):
> +#            ps | awk '/'"$1"'/ {print $1}'
> +#       Or
> +#       2) If there is "pidof -x", replace "pidof" with "pidof -x".
> +#
> +# pidofproc - print the pid of a process
> +# $1: the name of the process
> +pidofproc () {
> +
> +    # pidof output null when no program is running, so no "2>/dev/null".

This entire block is still indented with 4 spaces instead of tabs.

--
Darren

> +    pid=`pidof $1`
> +    case $? in
> +    0)
> +        echo $pid
> +        return 0
> +        ;;
> +    127)
> +        echo "ERROR: command pidof not found" >&2
> +        exit 127
> +        ;;
> +    *)
> +        return $?
> +        ;;
> +    esac
> +}
>  
>  machine_id() { # return the machine ID
>  	awk 'BEGIN { FS=": " } /Hardware/ \
> @@ -10,6 +39,5 @@ machine_id() { # return the machine ID
>  }
>  
>  killproc() { # kill the named process(es)
> -	pid=`/bin/pidof $1`
> -	[ "$pid" != "" ] && kill $pid
> +	pid=`pidofproc $1` && kill $pid
>  }

-- 
Darren Hart
Intel Open Source Technology Center
Yocto Project - Linux Kernel


  reply	other threads:[~2011-05-17  5:22 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-17  2:39 V3 [PATCH 0/4] Add meta-skeleton and a skeleton for init scripts Robert Yang
2011-05-17  2:39 ` V3 [PATCH 1/4] Add the layer meta-skeleton Robert Yang
2011-05-17  2:39 ` V3 [PATCH 2/4] Cleanup the whitespace in functions Robert Yang
2011-05-17  2:40 ` V3 [PATCH 3/4] Add pidofproc to ${sysconfdir}/init.d/functions Robert Yang
2011-05-17  5:22   ` Darren Hart [this message]
2011-05-17  2:40 ` V3 [PATCH 4/4] Add a skeleton for init scripts Robert Yang
2011-05-17  5:32   ` Darren Hart
2011-05-17  5:34 ` V3 [PATCH 0/4] Add meta-skeleton and " Darren Hart
2011-05-17  5:42   ` Robert Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4DD20621.6080305@linux.intel.com \
    --to=dvhart@linux.intel.com \
    --cc=liezhi.yang@windriver.com \
    --cc=poky@yoctoproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.