On 04/28/2011 10:25 AM, Ivana Hutarova Varekova wrote: > This patch adds option -h to cgexec tool > > Signed-off-by: Ivana Hutarova Varekova <varek...@redhat.com> Acked-By: Jan Safranek <jsafr...@redhat.com> + merged and pushed, thanks!
> --- > > src/tools/cgexec.c | 35 ++++++++++++++++++++++------------- > 1 files changed, 22 insertions(+), 13 deletions(-) > > diff --git a/doc/man/cgexec.1 b/doc/man/cgexec.1 > index bf197bd..e9d38d2 100644 > --- a/doc/man/cgexec.1 > +++ b/doc/man/cgexec.1 > @@ -7,7 +7,7 @@ > cgexec \- run the task in given control groups > > .SH SYNOPSIS > -\fBcgexec\fR [\fB-g\fR <\fIcontrollers>:<path\fR>] [--sticky] \fBcommand\fR > [\fIarguments\fR] > +\fBcgexec\fR [\fB-h\fR] [\fB-g\fR <\fIcontrollers>:<path\fR>] [--sticky] > \fBcommand\fR [\fIarguments\fR] > > .SH DESCRIPTION > The \fBcgexec\fR > @@ -32,6 +32,10 @@ If this option is not used then > cgroup based on \fB/etc/cgrules.conf\fR. > > .TP > +.B -h, --help > +Display this help and exit. > + > +.TP > .B --sticky > If running the task \fBcommand\fR with this option, the daemon of > service cgred (cgrulesengd process) does not change both the task > diff --git a/src/tools/cgexec.c b/src/tools/cgexec.c > index 8e0b4d8..f03f1fa 100644 > --- a/src/tools/cgexec.c > +++ b/src/tools/cgexec.c > @@ -35,10 +35,25 @@ > #include "tools-common.h" > > static struct option longopts[] = { > - {"sticky", no_argument, NULL, 's'}, > + {"sticky", no_argument, NULL, 's'}, > + {"help", no_argument, NULL, 'h'}, > {0, 0, 0, 0} > }; > > +static void usage(int status, const char *program_name) > +{ > + if (status != 0) > + fprintf(stderr, "Wrong input parameters," > + " try %s --help' for more information.\n", > + program_name); > + else { > + printf("Usage: %s [-h] [-g <controllers>:<path>] " > + "[--sticky] command [arguments] ...\n", > + program_name); > + } > +} > + > + > int main(int argc, char *argv[]) > { > int ret = 0, i; > @@ -50,17 +65,9 @@ int main(int argc, char *argv[]) > int c; > struct cgroup_group_spec *cgroup_list[CG_HIER_MAX]; > > - if (argc < 2) { > - fprintf(stderr, "Usage is %s" > - " [-g <list of controllers>:<relative path to cgroup>]" > - " [--sticky] command [arguments] \n", > - argv[0]); > - exit(2); > - } > - > memset(cgroup_list, 0, sizeof(cgroup_list)); > > - while ((c = getopt_long(argc, argv, "+g:s", longopts, NULL)) > 0) { > + while ((c = getopt_long(argc, argv, "+g:sh", longopts, NULL)) > 0) { > switch (c) { > case 'g': > ret = parse_cgroup_spec(cgroup_list, optarg, > @@ -75,16 +82,18 @@ int main(int argc, char *argv[]) > case 's': > flag_child |= CGROUP_DAEMON_UNCHANGE_CHILDREN; > break; > + case 'h': > + usage(0, argv[0]); > + exit(0); > default: > - fprintf(stderr, "Invalid command line option\n"); > + usage(1, argv[0]); > exit(1); > - break; > } > } > > /* Executable name */ > if (!argv[optind]) { > - fprintf(stderr, "No command specified\n"); > + usage(1, argv[0]); > exit(1); > } > > > > ------------------------------------------------------------------------------ > WhatsUp Gold - Download Free Network Management Software > The most intuitive, comprehensive, and cost-effective network > management toolset available today. Delivers lowest initial > acquisition cost and overall TCO of any competing solution. > http://p.sf.net/sfu/whatsupgold-sd > _______________________________________________ > Libcg-devel mailing list > Libcg-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/libcg-devel ------------------------------------------------------------------------------ WhatsUp Gold - Download Free Network Management Software The most intuitive, comprehensive, and cost-effective network management toolset available today. Delivers lowest initial acquisition cost and overall TCO of any competing solution. http://p.sf.net/sfu/whatsupgold-sd _______________________________________________ Libcg-devel mailing list Libcg-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libcg-devel