All of lore.kernel.org
 help / color / mirror / Atom feed
* chcpu exit code?
@ 2014-02-27  9:46 Bernhard Voelker
  2014-02-27 15:25 ` Dale R. Worley
  2014-02-28  7:53 ` Heiko Carstens
  0 siblings, 2 replies; 8+ messages in thread
From: Bernhard Voelker @ 2014-02-27  9:46 UTC (permalink / raw)
  To: Util-Linux

Although the man page does not mention the exit status, I think
it's wrong that 'chcpu' exits OK when an action failed or
when a bad CPU number was specified:

   $ ./chcpu -d 0 ; echo $?
   CPU 0 is not hot pluggable
   0

   $ ./chcpu -g 3 ; echo $?
   CPU 3 is not configurable
   0

   $ ./chcpu -e 4 ; echo $?
   CPU 4 does not exist
   0

WDYT?

Have a nice day,
Berny

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: chcpu exit code?
  2014-02-27  9:46 chcpu exit code? Bernhard Voelker
@ 2014-02-27 15:25 ` Dale R. Worley
  2014-02-28  7:53 ` Heiko Carstens
  1 sibling, 0 replies; 8+ messages in thread
From: Dale R. Worley @ 2014-02-27 15:25 UTC (permalink / raw)
  To: Bernhard Voelker; +Cc: util-linux

> From: Bernhard Voelker <mail@bernhard-voelker.de>
> 
> Although the man page does not mention the exit status, I think
> it's wrong that 'chcpu' exits OK when an action failed or
> when a bad CPU number was specified:

> WDYT?

I agree that it would be helpful if chcpu used the usual
success/failure convention for exit status.  The reason is that
sometimes one wants to use "set -e" in a script so that any command
that fails unexpectedly will cause processing to halt.  Similarly, if
one hands a command to a program to execute, a program that is set up
to execute generic commands supplied by some outside source usually
handles non-zero exit status specially by reporting that the command
failed, while treating zero exit statuses as not-to-be-remarked-upon.

Dale

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: chcpu exit code?
  2014-02-27  9:46 chcpu exit code? Bernhard Voelker
  2014-02-27 15:25 ` Dale R. Worley
@ 2014-02-28  7:53 ` Heiko Carstens
  2014-02-28  8:49   ` Bernhard Voelker
  2014-02-28  9:04   ` Karel Zak
  1 sibling, 2 replies; 8+ messages in thread
From: Heiko Carstens @ 2014-02-28  7:53 UTC (permalink / raw)
  To: Bernhard Voelker; +Cc: Util-Linux

On Thu, Feb 27, 2014 at 10:46:26AM +0100, Bernhard Voelker wrote:
> Although the man page does not mention the exit status, I think
> it's wrong that 'chcpu' exits OK when an action failed or
> when a bad CPU number was specified:
> 
>   $ ./chcpu -d 0 ; echo $?
>   CPU 0 is not hot pluggable
>   0
> 
>   $ ./chcpu -g 3 ; echo $?
>   CPU 3 is not configurable
>   0
> 
>   $ ./chcpu -e 4 ; echo $?
>   CPU 4 does not exist
>   0
> 
> WDYT?

The question is: what should chcpu return if it partially succeeded?

# chcpu -d 3-4
CPU 3 disabled
CPU 4 does not exist

If I remember correctly this was the reason to make it always return 0.

However, it is indeed valid to say if *everything* failed, it should
return an error. Hm?


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: chcpu exit code?
  2014-02-28  7:53 ` Heiko Carstens
@ 2014-02-28  8:49   ` Bernhard Voelker
  2014-02-28  9:04   ` Karel Zak
  1 sibling, 0 replies; 8+ messages in thread
From: Bernhard Voelker @ 2014-02-28  8:49 UTC (permalink / raw)
  To: Heiko Carstens; +Cc: Util-Linux

On 02/28/2014 08:53 AM, Heiko Carstens wrote:
> The question is: what should chcpu return if it partially succeeded?
>
> # chcpu -d 3-4
> CPU 3 disabled
> CPU 4 does not exist
>
> If I remember correctly this was the reason to make it always return 0.
>
> However, it is indeed valid to say if *everything* failed, it should
> return an error. Hm?

Indeed, e.g. df(1) also fails if only a single mount point
cannot be listed.  Otherwise, the calling script could not rely
on the exit code, and would still have to fall back to parsing
the output.

But thanks to your question I was reminded to have a look
at *where* chcpu writes messages:

   $ chcpu -d 3-4 > /dev/null
   $ chcpu -d 3-4 2> /dev/null
   CPU 3 is already disabled
   CPU 4 does not exist
   $

I.e. chcpu does not write the error diagnostic to stderr ... humm.

Have a nice day,
Berny


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: chcpu exit code?
  2014-02-28  7:53 ` Heiko Carstens
  2014-02-28  8:49   ` Bernhard Voelker
@ 2014-02-28  9:04   ` Karel Zak
  2014-03-03 11:23     ` Bernhard Voelker
  1 sibling, 1 reply; 8+ messages in thread
From: Karel Zak @ 2014-02-28  9:04 UTC (permalink / raw)
  To: Heiko Carstens; +Cc: Bernhard Voelker, Util-Linux

On Fri, Feb 28, 2014 at 08:53:55AM +0100, Heiko Carstens wrote:
> On Thu, Feb 27, 2014 at 10:46:26AM +0100, Bernhard Voelker wrote:
> > Although the man page does not mention the exit status, I think
> > it's wrong that 'chcpu' exits OK when an action failed or
> > when a bad CPU number was specified:
> > 
> >   $ ./chcpu -d 0 ; echo $?
> >   CPU 0 is not hot pluggable
> >   0
> > 
> >   $ ./chcpu -g 3 ; echo $?
> >   CPU 3 is not configurable
> >   0
> > 
> >   $ ./chcpu -e 4 ; echo $?
> >   CPU 4 does not exist
> >   0
> > 
> > WDYT?
> 
> The question is: what should chcpu return if it partially succeeded?
> 
> # chcpu -d 3-4
> CPU 3 disabled
> CPU 4 does not exist

 This is not so unusual situation, we have for example the same thing
 in mount -a where

   0 - success
  32 - mount failure
  64 - some mount succeeded

I think we can do something like this with chcpu, my suggestion is

   0 - success
   1 - failure
  64 - partial success

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: chcpu exit code?
  2014-02-28  9:04   ` Karel Zak
@ 2014-03-03 11:23     ` Bernhard Voelker
  2014-03-05 10:12       ` Karel Zak
  0 siblings, 1 reply; 8+ messages in thread
From: Bernhard Voelker @ 2014-03-03 11:23 UTC (permalink / raw)
  To: Karel Zak, Heiko Carstens; +Cc: Util-Linux

On 02/28/2014 10:04 AM, Karel Zak wrote:
> I think we can do something like this with chcpu, my suggestion is
>
>     0 - success
>     1 - failure
>    64 - partial success

+1

Thanks & have a nice day,
Berny

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: chcpu exit code?
  2014-03-03 11:23     ` Bernhard Voelker
@ 2014-03-05 10:12       ` Karel Zak
  2014-03-05 11:00         ` Bernhard Voelker
  0 siblings, 1 reply; 8+ messages in thread
From: Karel Zak @ 2014-03-05 10:12 UTC (permalink / raw)
  To: Bernhard Voelker; +Cc: Heiko Carstens, Util-Linux

On Mon, Mar 03, 2014 at 12:23:27PM +0100, Bernhard Voelker wrote:
> On 02/28/2014 10:04 AM, Karel Zak wrote:
> >I think we can do something like this with chcpu, my suggestion is
> >
> >    0 - success
> >    1 - failure
> >   64 - partial success
> 
> +1

 Fixed. Thanks for your report.

    Karel
-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: chcpu exit code?
  2014-03-05 10:12       ` Karel Zak
@ 2014-03-05 11:00         ` Bernhard Voelker
  0 siblings, 0 replies; 8+ messages in thread
From: Bernhard Voelker @ 2014-03-05 11:00 UTC (permalink / raw)
  To: Karel Zak; +Cc: Heiko Carstens, Util-Linux

On 03/05/2014 11:12 AM, Karel Zak wrote:
>   Fixed. Thanks for your report.

LGTM, thanks!

Have a nice day,
Berny


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-03-05 11:01 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-27  9:46 chcpu exit code? Bernhard Voelker
2014-02-27 15:25 ` Dale R. Worley
2014-02-28  7:53 ` Heiko Carstens
2014-02-28  8:49   ` Bernhard Voelker
2014-02-28  9:04   ` Karel Zak
2014-03-03 11:23     ` Bernhard Voelker
2014-03-05 10:12       ` Karel Zak
2014-03-05 11:00         ` Bernhard Voelker

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.