freebsd-dev/usr.sbin/pkg_install/lib/exec.c
Jordan K. Hubbard 1130b656e5 Make the long-awaited change from $Id$ to $FreeBSD$
This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore.  This update would have been
insane otherwise.
1997-01-14 07:20:47 +00:00

61 lines
1.4 KiB
C

#ifndef lint
static const char *rcsid = "$FreeBSD$";
#endif
/*
* FreeBSD install - a package for the installation and maintainance
* of non-core utilities.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Jordan K. Hubbard
* 18 July 1993
*
* Miscellaneous system routines.
*
*/
#include "lib.h"
/*
* Unusual system() substitute. Accepts format string and args,
* builds and executes command. Returns exit code.
*/
int
vsystem(const char *fmt, ...)
{
va_list args;
char *cmd;
int ret, maxargs;
maxargs = sysconf(_SC_ARG_MAX);
maxargs -= 32; /* some slop for the sh -c */
cmd = malloc(maxargs);
if (!cmd) {
whinge("vsystem can't alloc arg space");
return 1;
}
va_start(args, fmt);
if (vsnprintf(cmd, maxargs, fmt, args) > maxargs) {
whinge("vsystem args are too long");
return 1;
}
#ifdef DEBUG
printf("Executing %s\n", cmd);
#endif
ret = system(cmd);
va_end(args);
free(cmd);
return ret;
}