/*
*      SCCS:   @(#)install/userintf/gen_setlimit	1.1 (01/21/97)  VSXgen release 1.4
*
*	UniSoft Ltd., London, England
*/
/***********************************************************************

NAME:		gen_setlimit - user-modifiable setlimit() routine
PROJECT:	VSX (X/OPEN Validation Suite)
AUTHOR:		Geoff Clare, UniSoft Ltd.
DATE CREATED:	December 1996
MODIFICATIONS:

************************************************************************/

/*
 *	Setlimit() is used to reduce the output file size limit for 
 *	the process.  The argument is the value to be set in units of
 *	512 byte blocks, and will always be >= VSX_ULIMIT_BLKS.
 *	If the system supports the SIGXFSZ signal, setlimit() should
 *	set it to be ignored.
 *	Setlimit() returns the new limit, or -1L for failure.
 */

#include <signal.h>
#include <ulimit.h>

public long
setlimit(lim)
long lim;
{
#ifdef SIGXFSZ
	struct sigaction sact;
	sact.sa_handler = SIG_IGN;
	sact.sa_flags = 0;
	(void) sigemptyset(&sact.sa_mask);
	if (sigaction(SIGXFSZ, &sact, (struct sigaction *)0) == -1)
		return -1L;
#endif
	return ulimit(UL_SETFSIZE, lim);
}

