1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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);
}
|