* [patch] ipcs (in git) produces too much output
@ 2013-01-27 13:51 Benno Schulenberg
2013-01-27 20:27 ` Sami Kerola
2013-02-06 10:35 ` Karel Zak
0 siblings, 2 replies; 4+ messages in thread
From: Benno Schulenberg @ 2013-01-27 13:51 UTC (permalink / raw)
To: Util-Linux
[-- Attachment #1: Type: text/plain, Size: 1310 bytes --]
Hi,
According to the synopses in the help output and in the man page,
it should be possible to use 'ipcs' with just the '-i' option and
an ID.
$ ./ipcs --help | grep '<id>'
ipcs [resource] -i <id>
-i, --id <id> print details on resource identified by id
But when trying that, ipcs blurts out its entire help text.
$ ./ipcs -i 111111
[...]
In the help text it also says that '-a' is the default, but when
adding '-a' to the above command, ipcs now produces three texts:
$ ./ipcs -a -i 111111
Shared memory Segment shmid=111111
[...]
Semaphore Array semid=111111
[...]
ipcs: id 111111 not found
(The latter error message could be clearer, mentioning that it
refers to a message queue.)
Whereas older ipcs would in this case just print an error message:
$ /usr/bin/ipcs -a -i 111111
ipcs: shmctl failed: Invalid argument
(Not good either, but at least it's shorter.)
Attached first patch is an attempt to fix this. With the patch,
ipcs now prints a clear errror message instead of outputting the
entire help text:
$ ./ipcs -a -i 111111
ipcs: when using an ID, a single resource must be specified
The second patch improves the formatting and wording of the man
page -- it also mentions that the -a option is not as in POSIX.
Regards,
Benno
--
http://www.fastmail.fm - mmm... Fastmail...
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ipcs-report-an-error-when-i-is-used-with-multiple-re.patch --]
[-- Type: text/x-patch; name="0001-ipcs-report-an-error-when-i-is-used-with-multiple-re.patch", Size: 2816 bytes --]
From ae6bca4e8cb7d98d961b5288194aa3840ac43b73 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@justemail.net>
Date: Sun, 27 Jan 2013 13:09:51 +0100
Subject: [PATCH 1/2] ipcs: report an error when -i is used with multiple resources
Also put everything in POSIX order: queues, memory, sempahores.
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
---
sys-utils/ipcs.c | 38 +++++++++++++++++++-------------------
1 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/sys-utils/ipcs.c b/sys-utils/ipcs.c
index 1e1b022..352732a 100644
--- a/sys-utils/ipcs.c
+++ b/sys-utils/ipcs.c
@@ -77,13 +77,13 @@ static void __attribute__ ((__noreturn__)) usage(FILE * out)
int main (int argc, char **argv)
{
- int opt, msg = 0, sem = 0, shm = 0, id=0, print=0;
+ int opt, msg = 0, shm = 0, sem = 0, id = 0, specific = 0;
char format = NOTSPECIFIED;
int unit = IPC_UNIT_DEFAULT;
static const struct option longopts[] = {
{"id", required_argument, NULL, 'i'},
- {"shmems", no_argument, NULL, 'm'},
{"queues", no_argument, NULL, 'q'},
+ {"shmems", no_argument, NULL, 'm'},
{"semaphores", no_argument, NULL, 's'},
{"all", no_argument, NULL, 'a'},
{"time", no_argument, NULL, 't'},
@@ -97,7 +97,7 @@ int main (int argc, char **argv)
{"help", no_argument, NULL, 'h'},
{NULL, 0, NULL, 0}
};
- char options[] = "i:mqsatpclubVh";
+ char options[] = "i:qmsatpclubVh";
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
@@ -108,7 +108,7 @@ int main (int argc, char **argv)
switch (opt) {
case 'i':
id = atoi (optarg);
- print = 1;
+ specific = 1;
break;
case 'a':
msg = shm = sem = 1;
@@ -116,12 +116,12 @@ int main (int argc, char **argv)
case 'q':
msg = 1;
break;
- case 's':
- sem = 1;
- break;
case 'm':
shm = 1;
break;
+ case 's':
+ sem = 1;
+ break;
case 't':
format = TIME;
break;
@@ -153,20 +153,24 @@ int main (int argc, char **argv)
}
}
- if (print) {
+ if (specific && (msg + shm + sem != 1))
+ errx (EXIT_FAILURE,
+ _("when using an ID, a single resource must be specified"));
+ if (specific) {
+ if (msg)
+ print_msg (id, unit);
if (shm)
print_shm (id, unit);
if (sem)
print_sem (id);
- if (msg)
- print_msg (id, unit);
- if (!shm && !sem && !msg )
- usage (stderr);
} else {
- if ( !shm && !msg && !sem)
- msg = sem = shm = 1;
+ if (!msg && !shm && !sem)
+ msg = shm = sem = 1;
printf ("\n");
-
+ if (msg) {
+ do_msg (format, unit);
+ printf ("\n");
+ }
if (shm) {
do_shm (format, unit);
printf ("\n");
@@ -175,10 +179,6 @@ int main (int argc, char **argv)
do_sem (format);
printf ("\n");
}
- if (msg) {
- do_msg (format, unit);
- printf ("\n");
- }
}
return EXIT_SUCCESS;
}
--
1.7.0.4
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-docs-improve-wording-formatting-and-accuracy-of-ipcs.patch --]
[-- Type: text/x-patch; name="0002-docs-improve-wording-formatting-and-accuracy-of-ipcs.patch", Size: 4156 bytes --]
From 5a7e5260e6f74a2384533c50d94b76bd38e63dbd Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@justemail.net>
Date: Sun, 27 Jan 2013 14:40:19 +0100
Subject: [PATCH 2/2] docs: improve wording, formatting and accuracy of ipcs man page
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
---
sys-utils/ipcs.1 | 72 ++++++++++++++++++++++++++++++------------------------
1 files changed, 40 insertions(+), 32 deletions(-)
diff --git a/sys-utils/ipcs.1 b/sys-utils/ipcs.1
index 5fc3a81..fd7d452 100644
--- a/sys-utils/ipcs.1
+++ b/sys-utils/ipcs.1
@@ -1,76 +1,82 @@
.\" Copyright 1993 Rickard E. Faith (faith@cs.unc.edu)
.\" May be distributed under the GNU General Public License
-.TH IPCS "1" "September 2011" "util-linux" "User Commands"
+.TH IPCS "1" "January 2013" "util-linux" "User Commands"
.SH NAME
-ipcs \- provide information on ipc facilities
+ipcs \- provide information on IPC facilities
.SH SYNOPSIS
.B ipcs
-[resource] [...] [output\-format]
+.RB [ resource\-option "] [" output\-format ]
.br
.B ipcs
-[resource]
-.I \-i id
+.RB [ resource\-option ]
+.BI \-i " id"
.SH DESCRIPTION
.B ipcs
-provides information on the ipc facilities for which the calling process
-has read access.
+provides information on the inter-process communication facilities
+for which the calling process has read access.
.SH OPTIONS
.TP
\fB\-i\fR, \fB\-\-id\fR \fIid\fR
-Print details only on resource identified by
+Print details only on the resource identified by
.IR id .
.TP
\fB\-h\fR, \fB\-\-help\fR
-Display this help and exit.
+Display a help text and exit.
.TP
\fB\-V\fR, \fB\-\-version\fR
-Output version information and exit.
+Display version information and exit.
.SH "RESOURCE OPTIONS"
.TP
-\fB\-m\fR, \fB\-\-shmems\fR
-Write information about active shared memory segments.
-.TP
\fB\-q\fR, \fB\-\-queues\fR
Write information about active message queues.
.TP
+\fB\-m\fR, \fB\-\-shmems\fR
+Write information about active shared memory segments.
+.TP
\fB\-s\fR, \fB\-\-semaphores\fR
Write information about active semaphore sets.
.TP
\fB\-a\fR, \fB\-\-all\fR
-Write information about all resources (default).
+Write information about all three resources (default).
.SH "OUTPUT FORMATS"
+Of the options
+.BR \-c ,
+.BR \-l ,
+.BR \-p ,
+.BR \-t " and " \-u
+only one (the last one specified) takes effect.
+.TP
+\fB\-c\fR, \fB\-\-creator\fR
+Show creator and owner.
+.TP
+\fB\-l\fR, \fB\-\-limits\fR
+Show resource limits.
+.TP
+\fB\-p\fR, \fB\-\-pid\fR
+Show PIDs of creator and last operator.
.TP
\fB\-t\fR, \fB\-\-time\fR
-Write time information. Time of the last control operation that changed the
-access permissions for all facilities, time of the last
+Write time information. The time of the last control operation that changed
+the access permissions for all facilities, the time of the last
.I msgsnd()
and
.I msgrcv()
-operations on message queues, time of the last
+operations on message queues, the time of the last
.I shmat()
and
.I shmdt()
-operations on shared memory, and time of the last
+operations on shared memory, and the time of the last
.I semop()
operation on semaphores.
.TP
-\fB\-p\fR, \fB\-\-pid\fR
-Show creator and last operations PIDs.
-.TP
-\fB\-c\fR, \fB\-\-creator\fR
-Show creator and owner.
-.TP
-\fB\-l\fR, \fB\-\-limits\fR
-Show resource limits.
-.TP
\fB\-u\fR, \fB\-\-summary\fR
Show status summary.
.TP
-.B \-\-human
-Print sizes in human readable format.
-.TP
\fB\-b\fR, \fB\-\-bytes\fR
Print sizes in bytes.
+.TP
+.B \-\-human
+Print sizes in human-readable format.
.SH SEE ALSO
.BR ipcrm (1),
.BR ipcmk (1),
@@ -83,7 +89,8 @@ Print sizes in bytes.
.BR shmget (2)
.SH CONFORMING TO
The Linux ipcs utility is not fully compatible to the POSIX ipcs utility.
-The Linux version does not support the
+The Linux version does not support the POSIX
+.BR \-a ,
.B \-b
and
.B \-o
@@ -91,7 +98,8 @@ options, but does support the
.B \-l
and
.B \-u
-options not defined by POSIX. The portable application shall not use the
+options not defined by POSIX. A portable application shall not use the
+.BR \-a ,
.BR \-b ,
.BR \-o ,
.BR \-l ,
--
1.7.0.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [patch] ipcs (in git) produces too much output
2013-01-27 13:51 [patch] ipcs (in git) produces too much output Benno Schulenberg
@ 2013-01-27 20:27 ` Sami Kerola
2013-01-27 20:43 ` Benno Schulenberg
2013-02-06 10:35 ` Karel Zak
1 sibling, 1 reply; 4+ messages in thread
From: Sami Kerola @ 2013-01-27 20:27 UTC (permalink / raw)
To: Benno Schulenberg; +Cc: Util-Linux
On Sun, Jan 27, 2013 at 1:51 PM, Benno Schulenberg
<bensberg@justemail.net> wrote:
> According to the synopses in the help output and in the man page,
> it should be possible to use 'ipcs' with just the '-i' option and
> an ID.
>
> $ ./ipcs --help | grep '<id>'
> ipcs [resource] -i <id>
> -i, --id <id> print details on resource identified by id
>
> But when trying that, ipcs blurts out its entire help text.
>
> $ ./ipcs -i 111111
> [...]
>
> In the help text it also says that '-a' is the default, but when
> adding '-a' to the above command, ipcs now produces three texts:
>
> $ ./ipcs -a -i 111111
>
> Shared memory Segment shmid=111111
> [...]
>
> Semaphore Array semid=111111
> [...]
>
> ipcs: id 111111 not found
>
> (The latter error message could be clearer, mentioning that it
> refers to a message queue.)
>
> Whereas older ipcs would in this case just print an error message:
>
> $ /usr/bin/ipcs -a -i 111111
> ipcs: shmctl failed: Invalid argument
>
> (Not good either, but at least it's shorter.)
>
> Attached first patch is an attempt to fix this. With the patch,
> ipcs now prints a clear errror message instead of outputting the
> entire help text:
>
> $ ./ipcs -a -i 111111
> ipcs: when using an ID, a single resource must be specified
>
> The second patch improves the formatting and wording of the man
> page -- it also mentions that the -a option is not as in POSIX.
Hi Benno,
Both patches look pretty good. I just wonder would .SS make sense for
second level option headers?
diff --git a/sys-utils/ipcs.1 b/sys-utils/ipcs.1
index fd7d452..7c4f3fd 100644
--- a/sys-utils/ipcs.1
+++ b/sys-utils/ipcs.1
@@ -25,7 +25,7 @@ Display a help text and exit.
.TP
\fB\-V\fR, \fB\-\-version\fR
Display version information and exit.
-.SH "RESOURCE OPTIONS"
+.SS "RESOURCE OPTIONS"
.TP
\fB\-q\fR, \fB\-\-queues\fR
Write information about active message queues.
@@ -38,7 +38,7 @@ Write information about active semaphore sets.
.TP
\fB\-a\fR, \fB\-\-all\fR
Write information about all three resources (default).
-.SH "OUTPUT FORMATS"
+.SS "OUTPUT FORMATS"
Of the options
.BR \-c ,
.BR \-l ,
Either way, SH or SS,
Reviewed-by: Sami Kerola <kerolasa@iki.fi>
--
Sami Kerola
http://www.iki.fi/kerolasa/
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [patch] ipcs (in git) produces too much output
2013-01-27 20:27 ` Sami Kerola
@ 2013-01-27 20:43 ` Benno Schulenberg
0 siblings, 0 replies; 4+ messages in thread
From: Benno Schulenberg @ 2013-01-27 20:43 UTC (permalink / raw)
To: kerolasa; +Cc: Util-Linux
[-- Attachment #1: Type: text/plain, Size: 368 bytes --]
Hi Sami,
On Sun, Jan 27, 2013, at 21:27, Sami Kerola wrote:
> Both patches look pretty good. I just wonder would .SS make sense for
> second level option headers?
Yes, that looks nicer. Attached an updated patch for the man page.
It also makes a third subsection for --bytes and --human.
Regards,
Benno
--
http://www.fastmail.fm - Send your email first class
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0002-docs-improve-wording-formatting-and-accuracy-of-ipcs.patch --]
[-- Type: text/x-patch; name="0002-docs-improve-wording-formatting-and-accuracy-of-ipcs.patch", Size: 4229 bytes --]
From ed77954d18187fc8e4155c12c155d133c0a6a944 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@justemail.net>
Date: Sun, 27 Jan 2013 14:40:19 +0100
Subject: [PATCH 2/2] docs: improve wording, formatting and accuracy of ipcs man page
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
---
sys-utils/ipcs.1 | 73 ++++++++++++++++++++++++++++-------------------------
1 files changed, 39 insertions(+), 34 deletions(-)
diff --git a/sys-utils/ipcs.1 b/sys-utils/ipcs.1
index 5fc3a81..c070d1a 100644
--- a/sys-utils/ipcs.1
+++ b/sys-utils/ipcs.1
@@ -1,76 +1,79 @@
.\" Copyright 1993 Rickard E. Faith (faith@cs.unc.edu)
.\" May be distributed under the GNU General Public License
-.TH IPCS "1" "September 2011" "util-linux" "User Commands"
+.TH IPCS "1" "January 2013" "util-linux" "User Commands"
.SH NAME
-ipcs \- provide information on ipc facilities
+ipcs \- provide information on IPC facilities
.SH SYNOPSIS
.B ipcs
-[resource] [...] [output\-format]
+.RB [ resource\-option "] [" output\-format ]
.br
.B ipcs
-[resource]
-.I \-i id
+.RB [ resource\-option ]
+.BI \-i " id"
.SH DESCRIPTION
.B ipcs
-provides information on the ipc facilities for which the calling process
-has read access.
+provides information on the inter-process communication facilities
+for which the calling process has read access.
.SH OPTIONS
.TP
\fB\-i\fR, \fB\-\-id\fR \fIid\fR
-Print details only on resource identified by
+Print details only on the resource identified by
.IR id .
.TP
\fB\-h\fR, \fB\-\-help\fR
-Display this help and exit.
+Display a help text and exit.
.TP
\fB\-V\fR, \fB\-\-version\fR
-Output version information and exit.
-.SH "RESOURCE OPTIONS"
-.TP
-\fB\-m\fR, \fB\-\-shmems\fR
-Write information about active shared memory segments.
+Display version information and exit.
+.SS "Resource options"
.TP
\fB\-q\fR, \fB\-\-queues\fR
Write information about active message queues.
.TP
+\fB\-m\fR, \fB\-\-shmems\fR
+Write information about active shared memory segments.
+.TP
\fB\-s\fR, \fB\-\-semaphores\fR
Write information about active semaphore sets.
.TP
\fB\-a\fR, \fB\-\-all\fR
-Write information about all resources (default).
-.SH "OUTPUT FORMATS"
+Write information about all three resources (default).
+.SS "Output formats"
+Of these options only one takes effect: the last one specified.
+.TP
+\fB\-c\fR, \fB\-\-creator\fR
+Show creator and owner.
+.TP
+\fB\-l\fR, \fB\-\-limits\fR
+Show resource limits.
+.TP
+\fB\-p\fR, \fB\-\-pid\fR
+Show PIDs of creator and last operator.
.TP
\fB\-t\fR, \fB\-\-time\fR
-Write time information. Time of the last control operation that changed the
-access permissions for all facilities, time of the last
+Write time information. The time of the last control operation that changed
+the access permissions for all facilities, the time of the last
.I msgsnd()
and
.I msgrcv()
-operations on message queues, time of the last
+operations on message queues, the time of the last
.I shmat()
and
.I shmdt()
-operations on shared memory, and time of the last
+operations on shared memory, and the time of the last
.I semop()
operation on semaphores.
.TP
-\fB\-p\fR, \fB\-\-pid\fR
-Show creator and last operations PIDs.
-.TP
-\fB\-c\fR, \fB\-\-creator\fR
-Show creator and owner.
-.TP
-\fB\-l\fR, \fB\-\-limits\fR
-Show resource limits.
-.TP
\fB\-u\fR, \fB\-\-summary\fR
Show status summary.
-.TP
-.B \-\-human
-Print sizes in human readable format.
+.SS "Representation"
+These affect only the \fB\-l\fR (\fB\-\-limits\fR) option.
.TP
\fB\-b\fR, \fB\-\-bytes\fR
Print sizes in bytes.
+.TP
+.B \-\-human
+Print sizes in human-readable format.
.SH SEE ALSO
.BR ipcrm (1),
.BR ipcmk (1),
@@ -83,7 +86,8 @@ Print sizes in bytes.
.BR shmget (2)
.SH CONFORMING TO
The Linux ipcs utility is not fully compatible to the POSIX ipcs utility.
-The Linux version does not support the
+The Linux version does not support the POSIX
+.BR \-a ,
.B \-b
and
.B \-o
@@ -91,7 +95,8 @@ options, but does support the
.B \-l
and
.B \-u
-options not defined by POSIX. The portable application shall not use the
+options not defined by POSIX. A portable application shall not use the
+.BR \-a ,
.BR \-b ,
.BR \-o ,
.BR \-l ,
--
1.7.0.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [patch] ipcs (in git) produces too much output
2013-01-27 13:51 [patch] ipcs (in git) produces too much output Benno Schulenberg
2013-01-27 20:27 ` Sami Kerola
@ 2013-02-06 10:35 ` Karel Zak
1 sibling, 0 replies; 4+ messages in thread
From: Karel Zak @ 2013-02-06 10:35 UTC (permalink / raw)
To: Benno Schulenberg; +Cc: Util-Linux
On Sun, Jan 27, 2013 at 02:51:16PM +0100, Benno Schulenberg wrote:
> Subject: [PATCH 1/2] ipcs: report an error when -i is used with multiple resources
> Subject: [PATCH 2/2] docs: improve wording, formatting and accuracy of ipcs man page
Applied, thanks.
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-02-06 10:35 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-27 13:51 [patch] ipcs (in git) produces too much output Benno Schulenberg
2013-01-27 20:27 ` Sami Kerola
2013-01-27 20:43 ` Benno Schulenberg
2013-02-06 10:35 ` Karel Zak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox