diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2014-10-26 12:33:50 +0400 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2014-10-26 12:33:50 +0400 |
commit | 47e6e7c84f008a53061e661f31ae96629bc694ef (patch) | |
tree | 648a07f3b5b9d67ce19b0fd72e8caa1175c98f1a /qa/src/pmprintf.c | |
download | pcp-debian/3.9.10.tar.gz |
Debian 3.9.10debian/3.9.10debian
Diffstat (limited to 'qa/src/pmprintf.c')
-rw-r--r-- | qa/src/pmprintf.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/qa/src/pmprintf.c b/qa/src/pmprintf.c new file mode 100644 index 0000000..b00a86c --- /dev/null +++ b/qa/src/pmprintf.c @@ -0,0 +1,51 @@ +/* + * Copyright (c) 1997-2002 Silicon Graphics, Inc. All Rights Reserved. + */ + +#include <stdio.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <pcp/pmapi.h> + +int +main(int argc, char *argv[]) +{ + int sts, i; + int fd; + + if (argc < 2) { + fprintf(stderr, "Bad pmprintf invocation (need more args)\n"); + exit(1); + } + + /* + * Some stdio environments start with strange fd's open ... close + * 'em all to give us some breathing space + */ + for (fd = 3; fd < 100; fd++) + close(fd); + + /* + * for testing #634665 it helps to have a couple of extra + * open files ... see qa/505 + * ProPack 2.2 increased this to need 5 extra ones + */ + (void)open("/dev/null", O_RDONLY); + (void)open("/dev/null", O_RDONLY); + (void)open("/dev/null", O_RDONLY); + (void)open("/dev/null", O_RDONLY); + (void)open("/dev/null", O_RDONLY); + (void)open("/dev/null", O_RDONLY); + (void)open("/dev/null", O_RDONLY); + + for (i = 1; i < argc; i++) { + if ((sts = pmprintf("%s ", argv[i])) < 0) { + fprintf(stderr, "pmprintf: %s\n", pmErrStr(sts)); + } + } + + pmprintf("\n"); + pmflush(); + exit(0); +} |