4 #ifndef HAVE_SETPROCTITLE
10 #include <ac/setproctitle.h>
11 #include <ac/string.h>
12 #include <ac/stdarg.h>
15 * Copyright (c) 1990,1991 Regents of the University of Michigan.
16 * All rights reserved.
18 * Redistribution and use in source and binary forms are permitted
19 * provided that this notice is preserved and that due credit is given
20 * to the University of Michigan at Ann Arbor. The name of the University
21 * may not be used to endorse or promote products derived from this
22 * software without specific prior written permission. This software
23 * is provided ``as is'' without express or implied warranty.
26 char **Argv; /* pointer to original (main's) argv */
27 int Argc; /* original argc */
30 * takes a printf-style format string (fmt) and up to three parameters (a,b,c)
31 * this clobbers the original argv...
35 void setproctitle( const char *fmt, ... )
37 static char *endargv = (char *)0;
46 buf[sizeof(buf) - 1] = '\0';
47 vsnprintf( buf, sizeof(buf)-1, fmt, ap );
49 vsprintf( buf, fmt, ap ); /* hope it's not too long */
52 chokeme = "choke me! I don't have a doprnt() manual handy";
57 if ( endargv == (char *)0 ) {
58 /* set pointer to end of original argv */
59 endargv = Argv[ Argc-1 ] + strlen( Argv[ Argc-1 ] );
61 /* make ps print "([prog name])" */
65 if ( i > endargv - s - 2 ) {
71 while ( s < endargv ) *s++ = ' ';
73 #endif /* NOSETPROCTITLE */