1272343Sngie/*	$NetBSD: h_ps_strings2.c,v 1.1 2011/03/05 18:14:33 pgoyette Exp $	*/
2272343Sngie/*-
3272343Sngie * Copyright (c) 2011 The NetBSD Foundation, Inc.
4272343Sngie * All rights reserved.
5272343Sngie *
6272343Sngie * This code is derived from software contributed to The NetBSD Foundation
7272343Sngie * by Joerg Sonnenberger.
8272343Sngie *
9272343Sngie * Redistribution and use in source and binary forms, with or without
10272343Sngie * modification, are permitted provided that the following conditions
11272343Sngie * are met:
12272343Sngie *
13272343Sngie * 1. Redistributions of source code must retain the above copyright
14272343Sngie *    notice, this list of conditions and the following disclaimer.
15272343Sngie * 2. Redistributions in binary form must reproduce the above copyright
16272343Sngie *    notice, this list of conditions and the following disclaimer in
17272343Sngie *    the documentation and/or other materials provided with the
18272343Sngie *    distribution.
19272343Sngie *
20272343Sngie * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21272343Sngie * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22272343Sngie * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23272343Sngie * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
24272343Sngie * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25272343Sngie * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
26272343Sngie * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27272343Sngie * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28272343Sngie * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29272343Sngie * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
30272343Sngie * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31272343Sngie * SUCH DAMAGE.
32272343Sngie */
33272343Sngie
34272343Sngie#include <sys/types.h>
35272343Sngie#include <sys/exec.h>
36272343Sngie#include <err.h>
37272343Sngie#include <limits.h>
38272343Sngie#include <stdio.h>
39272343Sngie#include <stdlib.h>
40272343Sngie#include <string.h>
41272343Sngie#include <unistd.h>
42272343Sngie
43272343Sngie#define	LEN	16384
44272343Sngie
45272343Sngieextern struct ps_strings *__ps_strings;
46272343Sngie
47272343Sngieint
48272343Sngiemain(void)
49272343Sngie{
50272343Sngie	size_t i;
51272343Sngie	char buf[16];
52272343Sngie	char **argv;
53272343Sngie
54272343Sngie	if ((argv = calloc(LEN, sizeof(*argv))) == NULL)
55272343Sngie		errx(1, "calloc failed");
56272343Sngie	for (i = 0; i < LEN; ++i) {
57272343Sngie		snprintf(buf, sizeof(buf), "arg%04zx", i);
58272343Sngie		if ((argv[i] = strdup(buf)) == NULL)
59272343Sngie			errx(1, "strdup failed");
60272343Sngie	}
61272343Sngie	__ps_strings->ps_argvstr = argv;
62272343Sngie	__ps_strings->ps_nargvstr = LEN;
63272343Sngie
64272343Sngie	printf("Sleeping forever...\n");
65272343Sngie	do {
66272343Sngie		sleep(UINT_MAX);
67272343Sngie	} while /* CONSTCOND */ (1);
68272343Sngie	return 0;
69272343Sngie}
70