mirror of
https://github.com/troglobit/finit.git
synced 2026-10-27 12:20:54 +00:00
initctl: add -1,--once flag for top command
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
da95c7d80e
commit
99a8cf3eb7
3 files changed
+13
-1
No files matched your search
@@ -446,6 +446,7 @@ int show_cgtop(char *arg)
|
|||||||
{
|
{
|
||||||
struct sysinfo si = { 0 };
|
struct sysinfo si = { 0 };
|
||||||
char path[512];
|
char path[512];
|
||||||
|
int laps = 0;
|
||||||
|
|
||||||
if (!arg)
|
if (!arg)
|
||||||
arg = FINIT_CGPATH;
|
arg = FINIT_CGPATH;
|
||||||
@@ -465,6 +466,9 @@ int show_cgtop(char *arg)
|
|||||||
if (heading)
|
if (heading)
|
||||||
print_header(" VmSIZE RSS VmLIB %%MEM %%CPU GROUP");
|
print_header(" VmSIZE RSS VmLIB %%MEM %%CPU GROUP");
|
||||||
cgroup_tree(arg, NULL, 1);
|
cgroup_tree(arg, NULL, 1);
|
||||||
|
|
||||||
|
if (ionce && laps++)
|
||||||
|
break;
|
||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+8
-1
@@ -50,6 +50,7 @@ struct cmd {
|
|||||||
|
|
||||||
int icreate = 0;
|
int icreate = 0;
|
||||||
int iforce = 0;
|
int iforce = 0;
|
||||||
|
int ionce = 0;
|
||||||
int heading = 1;
|
int heading = 1;
|
||||||
int verbose = 0;
|
int verbose = 0;
|
||||||
int plain = 0;
|
int plain = 0;
|
||||||
@@ -714,6 +715,7 @@ static int usage(int rc)
|
|||||||
" -b, --batch Batch mode, no screen size probing\n"
|
" -b, --batch Batch mode, no screen size probing\n"
|
||||||
" -c, --create Create missing paths (and files) as needed\n"
|
" -c, --create Create missing paths (and files) as needed\n"
|
||||||
" -f, --force Ignore missing files and arguments, never prompt\n"
|
" -f, --force Ignore missing files and arguments, never prompt\n"
|
||||||
|
" -1, --once Only one lap in commands like 'top'\n"
|
||||||
" -p, --plain Use plain table headings, no ctrl chars\n"
|
" -p, --plain Use plain table headings, no ctrl chars\n"
|
||||||
" -t, --no-heading Skip table headings\n"
|
" -t, --no-heading Skip table headings\n"
|
||||||
" -v, --verbose Verbose output\n"
|
" -v, --verbose Verbose output\n"
|
||||||
@@ -842,6 +844,7 @@ int main(int argc, char *argv[])
|
|||||||
{ "create", 0, NULL, 'c' },
|
{ "create", 0, NULL, 'c' },
|
||||||
{ "force", 0, NULL, 'f' },
|
{ "force", 0, NULL, 'f' },
|
||||||
{ "help", 0, NULL, 'h' },
|
{ "help", 0, NULL, 'h' },
|
||||||
|
{ "once", 0, NULL, '1' },
|
||||||
{ "plain", 0, NULL, 'p' },
|
{ "plain", 0, NULL, 'p' },
|
||||||
{ "no-heading", 0, NULL, 't' },
|
{ "no-heading", 0, NULL, 't' },
|
||||||
{ "verbose", 0, NULL, 'v' },
|
{ "verbose", 0, NULL, 'v' },
|
||||||
@@ -898,8 +901,12 @@ int main(int argc, char *argv[])
|
|||||||
if (transform(progname(argv[0])))
|
if (transform(progname(argv[0])))
|
||||||
return reboot_main(argc, argv);
|
return reboot_main(argc, argv);
|
||||||
|
|
||||||
while ((c = getopt_long(argc, argv, "bcfh?ptv", long_options, NULL)) != EOF) {
|
while ((c = getopt_long(argc, argv, "1bcfh?ptv", long_options, NULL)) != EOF) {
|
||||||
switch(c) {
|
switch(c) {
|
||||||
|
case '1':
|
||||||
|
ionce = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'b':
|
case 'b':
|
||||||
interactive = 0;
|
interactive = 0;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
extern int icreate; /* initctl -c */
|
extern int icreate; /* initctl -c */
|
||||||
extern int iforce; /* initctl -f */
|
extern int iforce; /* initctl -f */
|
||||||
|
extern int ionce; /* initctl -1 */
|
||||||
extern int heading; /* initctl -t */
|
extern int heading; /* initctl -t */
|
||||||
extern int verbose; /* initctl -v */
|
extern int verbose; /* initctl -v */
|
||||||
extern int plain; /* initctl -p */
|
extern int plain; /* initctl -p */
|
||||||
|
|||||||
Reference in new issue
Block a user