16#ifndef HAVE_SETPROCTITLE
17#if defined(__linux__) || defined(__APPLE__)
18static char **fpm_env_argv =
NULL;
19static size_t fpm_env_argv_len = 0;
24# ifdef (__sparc__ || __sparc)
36 if ((
cp = malloc(length)) == 0) {
48 char *var =
alloca(name_len + 1 + value_len + 1);
56 var[name_len + 1 + value_len] =
'\0';
73 char *eq =
strchr(*envp,
'=');
77 if (eq)
s[eq - *envp] =
'\0';
104static char * nvmatch(
char *s1,
char *s2)
112 if(*s1 ==
'\0' && *(s2-1) ==
'=') {
122#if defined(HAVE_SETPROCTITLE_FAST)
123 setproctitle_fast(
"%s", title);
124#elif defined(HAVE_SETPROCTITLE)
125 setproctitle(
"%s", title);
126#elif defined(__linux__) || defined(__APPLE__)
128 if (fpm_env_argv !=
NULL && fpm_env_argv_len > prefixlen + 3) {
129 memset(fpm_env_argv[0], 0, fpm_env_argv_len);
131 strncpy(fpm_env_argv[0] + prefixlen, title, fpm_env_argv_len - prefixlen - 2);
132 fpm_env_argv[1] =
NULL;
171 if (*kv->
value ==
'$') {
200#ifndef HAVE_SETPROCTITLE
201#if defined(__linux__) || defined(__APPLE__)
203static void fpm_env_cleanup(
int which,
void *
arg)
205 char** allocated_environ =
environ;
206 if (allocated_environ) {
209 while (allocated_environ[i]) {
210 free(allocated_environ[i]);
213 free(allocated_environ);
225 if (0 > fpm_env_conf_wp(wp)) {
229#ifndef HAVE_SETPROCTITLE
230#if defined(__linux__) || defined(__APPLE__)
269 fpm_env_argv_len =
last - first;
273 unsigned int env_nb = 0
U;
283 if ((new_environ = malloc((1U + env_nb) *
sizeof (
char *))) ==
NULL) {
286 new_environ[env_nb] =
NULL;
287 while (env_nb > 0
U) {
289 new_environ[env_nb] = strdup(
environ[env_nb]);
getenv(?string $name=null, bool $local_only=false)
putenv(string $assignment)
strchr(string $haystack, string $needle, bool $before_needle=false)
memset(ptr, 0, type->size)
struct fpm_globals_s fpm_globals
int fpm_cleanup_add(int type, void(*cleanup)(int, void *), void *arg)
@ FPM_CLEANUP_PARENT_EXIT_MAIN
void fpm_env_setproctitle(char *title)
void unsetenv(const char *name)
int fpm_env_init_child(struct fpm_worker_pool_s *wp)
int fpm_env_init_main(void)
int setenv(char *name, char *value, int overwrite)
#define SETPROCTITLE_PREFIX
struct fpm_worker_pool_s * fpm_worker_all_pools
struct fpm_worker_pool_config_s * config
struct fpm_worker_pool_s * next
struct key_value_s * next
strcmp(string $string1, string $string2)