h_ps_strings2.c revision 1.1
11.1Spgoyette/*	$NetBSD: h_ps_strings2.c,v 1.1 2011/03/05 18:14:33 pgoyette Exp $	*/
21.1Spgoyette/*-
31.1Spgoyette * Copyright (c) 2011 The NetBSD Foundation, Inc.
41.1Spgoyette * All rights reserved.
51.1Spgoyette *
61.1Spgoyette * This code is derived from software contributed to The NetBSD Foundation
71.1Spgoyette * by Joerg Sonnenberger.
81.1Spgoyette *
91.1Spgoyette * Redistribution and use in source and binary forms, with or without
101.1Spgoyette * modification, are permitted provided that the following conditions
111.1Spgoyette * are met:
121.1Spgoyette *
131.1Spgoyette * 1. Redistributions of source code must retain the above copyright
141.1Spgoyette *    notice, this list of conditions and the following disclaimer.
151.1Spgoyette * 2. Redistributions in binary form must reproduce the above copyright
161.1Spgoyette *    notice, this list of conditions and the following disclaimer in
171.1Spgoyette *    the documentation and/or other materials provided with the
181.1Spgoyette *    distribution.
191.1Spgoyette *
201.1Spgoyette * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
211.1Spgoyette * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
221.1Spgoyette * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
231.1Spgoyette * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
241.1Spgoyette * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
251.1Spgoyette * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
261.1Spgoyette * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
271.1Spgoyette * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
281.1Spgoyette * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
291.1Spgoyette * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
301.1Spgoyette * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
311.1Spgoyette * SUCH DAMAGE.
321.1Spgoyette */
331.1Spgoyette
341.1Spgoyette#include <sys/types.h>
351.1Spgoyette#include <sys/exec.h>
361.1Spgoyette#include <err.h>
371.1Spgoyette#include <limits.h>
381.1Spgoyette#include <stdio.h>
391.1Spgoyette#include <stdlib.h>
401.1Spgoyette#include <string.h>
411.1Spgoyette#include <unistd.h>
421.1Spgoyette
431.1Spgoyette#define	LEN	16384
441.1Spgoyette
451.1Spgoyetteextern struct ps_strings *__ps_strings;
461.1Spgoyette
471.1Spgoyetteint
481.1Spgoyettemain(void)
491.1Spgoyette{
501.1Spgoyette	size_t i;
511.1Spgoyette	char buf[16];
521.1Spgoyette	char **argv;
531.1Spgoyette
541.1Spgoyette	if ((argv = calloc(LEN, sizeof(*argv))) == NULL)
551.1Spgoyette		errx(1, "calloc failed");
561.1Spgoyette	for (i = 0; i < LEN; ++i) {
571.1Spgoyette		snprintf(buf, sizeof(buf), "arg%04zx", i);
581.1Spgoyette		if ((argv[i] = strdup(buf)) == NULL)
591.1Spgoyette			errx(1, "strdup failed");
601.1Spgoyette	}
611.1Spgoyette	__ps_strings->ps_argvstr = argv;
621.1Spgoyette	__ps_strings->ps_nargvstr = LEN;
631.1Spgoyette
641.1Spgoyette	printf("Sleeping forever...\n");
651.1Spgoyette	do {
661.1Spgoyette		sleep(UINT_MAX);
671.1Spgoyette	} while /* CONSTCOND */ (1);
681.1Spgoyette	return 0;
691.1Spgoyette}
70