1*57718be8SEnji Cooper /* $NetBSD: h_ps_strings2.c,v 1.1 2011/03/05 18:14:33 pgoyette Exp $ */
2*57718be8SEnji Cooper /*-
3*57718be8SEnji Cooper * Copyright (c) 2011 The NetBSD Foundation, Inc.
4*57718be8SEnji Cooper * All rights reserved.
5*57718be8SEnji Cooper *
6*57718be8SEnji Cooper * This code is derived from software contributed to The NetBSD Foundation
7*57718be8SEnji Cooper * by Joerg Sonnenberger.
8*57718be8SEnji Cooper *
9*57718be8SEnji Cooper * Redistribution and use in source and binary forms, with or without
10*57718be8SEnji Cooper * modification, are permitted provided that the following conditions
11*57718be8SEnji Cooper * are met:
12*57718be8SEnji Cooper *
13*57718be8SEnji Cooper * 1. Redistributions of source code must retain the above copyright
14*57718be8SEnji Cooper * notice, this list of conditions and the following disclaimer.
15*57718be8SEnji Cooper * 2. Redistributions in binary form must reproduce the above copyright
16*57718be8SEnji Cooper * notice, this list of conditions and the following disclaimer in
17*57718be8SEnji Cooper * the documentation and/or other materials provided with the
18*57718be8SEnji Cooper * distribution.
19*57718be8SEnji Cooper *
20*57718be8SEnji Cooper * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21*57718be8SEnji Cooper * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22*57718be8SEnji Cooper * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23*57718be8SEnji Cooper * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24*57718be8SEnji Cooper * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25*57718be8SEnji Cooper * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
26*57718be8SEnji Cooper * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27*57718be8SEnji Cooper * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28*57718be8SEnji Cooper * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29*57718be8SEnji Cooper * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
30*57718be8SEnji Cooper * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31*57718be8SEnji Cooper * SUCH DAMAGE.
32*57718be8SEnji Cooper */
33*57718be8SEnji Cooper
34*57718be8SEnji Cooper #include <sys/types.h>
35*57718be8SEnji Cooper #include <sys/exec.h>
36*57718be8SEnji Cooper #include <err.h>
37*57718be8SEnji Cooper #include <limits.h>
38*57718be8SEnji Cooper #include <stdio.h>
39*57718be8SEnji Cooper #include <stdlib.h>
40*57718be8SEnji Cooper #include <string.h>
41*57718be8SEnji Cooper #include <unistd.h>
42*57718be8SEnji Cooper
43*57718be8SEnji Cooper #define LEN 16384
44*57718be8SEnji Cooper
45*57718be8SEnji Cooper extern struct ps_strings *__ps_strings;
46*57718be8SEnji Cooper
47*57718be8SEnji Cooper int
main(void)48*57718be8SEnji Cooper main(void)
49*57718be8SEnji Cooper {
50*57718be8SEnji Cooper size_t i;
51*57718be8SEnji Cooper char buf[16];
52*57718be8SEnji Cooper char **argv;
53*57718be8SEnji Cooper
54*57718be8SEnji Cooper if ((argv = calloc(LEN, sizeof(*argv))) == NULL)
55*57718be8SEnji Cooper errx(1, "calloc failed");
56*57718be8SEnji Cooper for (i = 0; i < LEN; ++i) {
57*57718be8SEnji Cooper snprintf(buf, sizeof(buf), "arg%04zx", i);
58*57718be8SEnji Cooper if ((argv[i] = strdup(buf)) == NULL)
59*57718be8SEnji Cooper errx(1, "strdup failed");
60*57718be8SEnji Cooper }
61*57718be8SEnji Cooper __ps_strings->ps_argvstr = argv;
62*57718be8SEnji Cooper __ps_strings->ps_nargvstr = LEN;
63*57718be8SEnji Cooper
64*57718be8SEnji Cooper printf("Sleeping forever...\n");
65*57718be8SEnji Cooper do {
66*57718be8SEnji Cooper sleep(UINT_MAX);
67*57718be8SEnji Cooper } while /* CONSTCOND */ (1);
68*57718be8SEnji Cooper return 0;
69*57718be8SEnji Cooper }
70