crossroads

Git mirror of https://crossroads.e-tunity.com/
git clone git://git.finwo.net/app/crossroads
Log | Files | Refs

createcommandlinespace.c (1262B)


      1 /*************************************************************************
      2  * This file is part of Crosroads 1.23, a load balancer and fail over
      3  * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL.
      4  * Visit http://crossroads.e-tunity.com for information.
      5  *************************************************************************/
      6 #include "crossroads.h"
      7 
      8 void create_commandline_space () {
      9     char **argv;
     10     int i;
     11     
     12     /* Here's a dirty hack for Linux systems. We're going to get
     13      * daemonized (unless -f was given) and we'll want to change the
     14      * program name as it appears in the ps list.
     15      * So we re-exec ourselves with a dummy -i flag that creates
     16      * space on the commanedline.
     17      */
     18 #   if SET_PROC_TITLE_BY_ARGV == 1
     19     if (! iflag_present) {
     20 	argv = xmalloc ( (org_argc + 2) * sizeof(char*));
     21 	
     22 	argv[0] = org_argv[0];
     23 	argv[1] = "-ixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
     24 	          "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
     25 	argv[org_argc + 1] = 0;
     26 
     27 	for (i = 1; i < org_argc; i++)
     28 	    argv[i + 1] = org_argv[i];
     29 	argv[org_argc + 1] = 0;
     30 
     31 	execv (argv[0], argv);
     32 	execvp (argv[0], argv);
     33 	error ("Failed to re-exec program: %s",
     34 	       strerror(errno));
     35     }
     36 #   endif
     37 }