summaryrefslogtreecommitdiffstats
path: root/libblkid/setproctitle.c
diff options
context:
space:
mode:
authorbigbiff <bigbiff@teamw.in>2015-01-02 01:44:14 +0100
committerDees Troy <dees_troy@teamw.in>2015-01-05 04:38:42 +0100
commit7b4c7a681cc4c0a53dc8a8baf4853e921cfbf5de (patch)
treefb69cb515cb4ab675d5850684cc402100b7a2a22 /libblkid/setproctitle.c
parentcrypto: remove unused libs and clean up makefile (diff)
downloadandroid_bootable_recovery-7b4c7a681cc4c0a53dc8a8baf4853e921cfbf5de.tar
android_bootable_recovery-7b4c7a681cc4c0a53dc8a8baf4853e921cfbf5de.tar.gz
android_bootable_recovery-7b4c7a681cc4c0a53dc8a8baf4853e921cfbf5de.tar.bz2
android_bootable_recovery-7b4c7a681cc4c0a53dc8a8baf4853e921cfbf5de.tar.lz
android_bootable_recovery-7b4c7a681cc4c0a53dc8a8baf4853e921cfbf5de.tar.xz
android_bootable_recovery-7b4c7a681cc4c0a53dc8a8baf4853e921cfbf5de.tar.zst
android_bootable_recovery-7b4c7a681cc4c0a53dc8a8baf4853e921cfbf5de.zip
Diffstat (limited to 'libblkid/setproctitle.c')
-rw-r--r--libblkid/setproctitle.c74
1 files changed, 0 insertions, 74 deletions
diff --git a/libblkid/setproctitle.c b/libblkid/setproctitle.c
deleted file mode 100644
index 4bcf8c8a9..000000000
--- a/libblkid/setproctitle.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * set process title for ps (from sendmail)
- *
- * Clobbers argv of our main procedure so ps(1) will display the title.
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdarg.h>
-
-#include "setproctitle.h"
-
-#ifndef SPT_BUFSIZE
-# define SPT_BUFSIZE 2048
-#endif
-
-extern char **environ;
-
-static char **argv0;
-static int argv_lth;
-
-void initproctitle (int argc, char **argv)
-{
- int i;
- char **envp = environ;
-
- /*
- * Move the environment so we can reuse the memory.
- * (Code borrowed from sendmail.)
- * WARNING: ugly assumptions on memory layout here;
- * if this ever causes problems, #undef DO_PS_FIDDLING
- */
- for (i = 0; envp[i] != NULL; i++)
- continue;
-
- environ = (char **) malloc(sizeof(char *) * (i + 1));
- if (environ == NULL)
- return;
-
- for (i = 0; envp[i] != NULL; i++)
- if ((environ[i] = strdup(envp[i])) == NULL)
- return;
- environ[i] = NULL;
-
- argv0 = argv;
- if (i > 0)
- argv_lth = envp[i-1] + strlen(envp[i-1]) - argv0[0];
- else
- argv_lth = argv0[argc-1] + strlen(argv0[argc-1]) - argv0[0];
-}
-
-void setproctitle (const char *prog, const char *txt)
-{
- int i;
- char buf[SPT_BUFSIZE];
-
- if (!argv0)
- return;
-
- if (strlen(prog) + strlen(txt) + 5 > SPT_BUFSIZE)
- return;
-
- sprintf(buf, "%s -- %s", prog, txt);
-
- i = strlen(buf);
- if (i > argv_lth - 2) {
- i = argv_lth - 2;
- buf[i] = '\0';
- }
- memset(argv0[0], '\0', argv_lth); /* clear the memory area */
- strcpy(argv0[0], buf);
-
- argv0[1] = NULL;
-}