summaryrefslogtreecommitdiff
path: root/selfrestart.c
diff options
context:
space:
mode:
authorAndrew Guschin <guschin.drew@gmail.com>2023-05-24 19:42:32 +0400
committerAndrew Guschin <guschin@altlinux.org>2023-07-27 21:25:25 +0400
commit5a7792579bbe1c1b443682d9924a1929e7acd555 (patch)
treef831b4412c0b071cba4a05ca6c50d7dbdbbd058e /selfrestart.c
parente3344f703551d81b4841f3f7bd444c5c30b18688 (diff)
Bump to v6.4
Diffstat (limited to 'selfrestart.c')
-rw-r--r--selfrestart.c65
1 files changed, 0 insertions, 65 deletions
diff --git a/selfrestart.c b/selfrestart.c
deleted file mode 100644
index d695d48..0000000
--- a/selfrestart.c
+++ /dev/null
@@ -1,65 +0,0 @@
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-/**
- * Magically finds the current's executable path
- *
- * I'm doing the do{}while(); trick because Linux (what I'm running) is not
- * POSIX compilant and so lstat() cannot be trusted on /proc entries
- *
- * @return char* the path of the current executable
- */
-char *get_dwm_path(){
- struct stat s;
- int r, length, rate = 42;
- char *path = NULL;
-
- if(lstat("/proc/self/exe", &s) == -1){
- perror("lstat:");
- return NULL;
- }
-
- length = s.st_size + 1 - rate;
-
- do{
- length+=rate;
-
- free(path);
- path = malloc(sizeof(char) * length);
-
- if(path == NULL){
- perror("malloc:");
- return NULL;
- }
-
- r = readlink("/proc/self/exe", path, length);
-
- if(r == -1){
- perror("readlink:");
- return NULL;
- }
- }while(r >= length);
-
- path[r] = '\0';
-
- return path;
-}
-
-/**
- * self-restart
- *
- * Initially inspired by: Yu-Jie Lin
- * https://sites.google.com/site/yjlnotes/notes/dwm
- */
-void self_restart(const Arg *arg) {
- char *const argv[] = {get_dwm_path(), NULL};
-
- if(argv[0] == NULL){
- return;
- }
-
- execv(argv[0], argv);
-}