KInit
Go to the documentation of this file.
24#include <config-kdeinit.h>
33#define PF_ARGV_WRITEABLE 2
34#define PF_ARGV_PSTAT 3
35#define PF_ARGV_PSSTRINGS 4
37#ifdef HAVE_SETPROCTITLE
38# define PF_ARGV_TYPE PF_ARGV_NONE
39# ifdef HAVE_SYS_TYPES_H
40# include <sys/types.h>
48# define PF_ARGV_TYPE PF_ARGV_NEW
50# define PF_ARGV_TYPE PF_ARGV_WRITEABLE
52# if defined(HAVE_SYS_PSTAT_H) && defined(HAVE_PSTAT)
53# include <sys/pstat.h>
55# define PF_ARGV_TYPE PF_ARGV_PSTAT
58# ifdef HAVE_SYS_EXEC_H
61# include <machine/vmparam.h>
63# define PF_ARGV_TYPE PF_ARGV_PSSTRINGS
72extern char *__progname;
74#ifdef HAVE___PROGNAME_FULL
75extern char *__progname_full;
81#if PF_ARGV_TYPE == PF_ARGV_WRITEABLE
90 register int i, envpsize;
94 for ( i = envpsize = 0; envp[i] != NULL; i++ ) {
95 envpsize += strlen(envp[i]) + 1;
98 if ((p = (
char **) malloc((i + 1) *
sizeof(
char *))) != NULL) {
101 for (i = 0; envp[i] != NULL; i++) {
102 if ((
environ[i] =
static_cast<char *
>(malloc(strlen(envp[i]) + 1))) != NULL) {
112# if PF_ARGV_TYPE == PF_ARGV_WRITEABLE
113 for (i = 0; i < argc; i++) {
120 for (i = 0; envp[i] != NULL; i++) {
122 if (!strncmp(envp[i],
"XDG_", 4))
125 LastArgv = envp[i] + strlen(envp[i]);
130# ifdef HAVE___PROGNAME
134 __progname = strdup(
"kdeinit4");
136# ifdef HAVE___PROGNAME_FULL
138 __progname_full = strdup(
argv[0]);
144 static char statbuf[BUFSIZ];
146#ifndef HAVE_SETPROCTITLE
147# if PF_ARGV_TYPE == PF_ARGV_PSTAT
160 memset(statbuf, 0,
sizeof(statbuf));
162#ifdef HAVE_SETPROCTITLE
163# if __FreeBSD__ >= 4 && !defined(FREEBSD4_0) && !defined(FREEBSD4_1)
165 vsnprintf(statbuf,
sizeof(statbuf), fmt, msg);
169 snprintf(statbuf,
sizeof(statbuf),
"%s",
"kdeinit4: ");
170 vsnprintf(statbuf + strlen(statbuf),
171 sizeof(statbuf) - strlen(statbuf),
176 setproctitle(
"%s", statbuf);
180 snprintf(statbuf,
sizeof(statbuf),
"%s",
"kdeinit4: ");
181 vsnprintf(statbuf + strlen(statbuf),
182 sizeof(statbuf) - strlen(statbuf),
190#ifdef HAVE_SETPROCTITLE
195# if PF_ARGV_TYPE == PF_ARGV_NEW
201# if PF_ARGV_TYPE == PF_ARGV_WRITEABLE
204 snprintf(
Argv[0], maxlen,
"%s", statbuf);
218# if PF_ARGV_TYPE == PF_ARGV_PSTAT
219 pst.pst_command = statbuf;
220 pstat(PSTAT_SETCMD, pst, i, 0, 0);
223# if PF_ARGV_TYPE == PF_ARGV_PSSTRINGS
224 PS_STRINGS->ps_nargvstr = 1;
225 PS_STRINGS->ps_argvstr = statbuf;
void proctitle_set(const char *fmt,...)
Change the process title.
void proctitle_init(int argc, char *argv[], char *envp[])
Set up the memory space for setting the proctitle.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by
doxygen 1.9.6 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.