Back to index

openldap  2.4.31
Functions | Variables
setproctitle.c File Reference
#include "portable.h"
#include <stdio.h>
#include <ac/stdlib.h>
#include <ac/setproctitle.h>
#include <ac/string.h>
#include <ac/stdarg.h>

Go to the source code of this file.

Functions

void setproctitle (const char *fmt,...)

Variables

char ** Argv
int Argc

Function Documentation

void setproctitle ( const char *  fmt,
  ... 
)

Definition at line 47 of file setproctitle.c.

{
       static char *endargv = (char *)0;
       char   *s;
       int           i;
       char   buf[ 1024 ];
       va_list       ap;

       va_start(ap, fmt);

       buf[sizeof(buf) - 1] = '\0';
       vsnprintf( buf, sizeof(buf)-1, fmt, ap );

       va_end(ap);

       if ( endargv == (char *)0 ) {
              /* set pointer to end of original argv */
              endargv = Argv[ Argc-1 ] + strlen( Argv[ Argc-1 ] );
       }
       /* make ps print "([prog name])" */
       s = Argv[0];
       *s++ = '-';
       i = strlen( buf );
       if ( i > endargv - s - 2 ) {
              i = endargv - s - 2;
              buf[ i ] = '\0';
       }
       strcpy( s, buf );
       s += i;
       while ( s < endargv ) *s++ = ' ';
}

Variable Documentation

Definition at line 39 of file setproctitle.c.

char** Argv

Definition at line 38 of file setproctitle.c.