[hackers] [slock] revert using argv0 and minor fixup || Markus Teich

From: <git_AT_suckless.org>
Date: Sat, 27 Feb 2016 15:07:48 +0100 (CET)

commit ec46680fe10ffc69007b0a8b29d9e69c72704053
Author: Markus Teich <markus.teich_AT_stusta.mhn.de>
AuthorDate: Mon Feb 15 14:00:56 2016 +0100
Commit: Markus Teich <markus.teich_AT_stusta.mhn.de>
CommitDate: Mon Feb 15 14:00:56 2016 +0100

    revert using argv0 and minor fixup
    
    - use hardcoded "slock" instead of argv[0]
    - add "slock: " to fprintf calls, where it was missing
    - revert `argc--, argv++` shifting

diff --git a/slock.c b/slock.c
index a0ffed0..2aa395e 100644
--- a/slock.c
+++ b/slock.c
_AT_@ -46,15 +46,14 @@ static Bool failure = False;
 static Bool rr;
 static int rrevbase;
 static int rrerrbase;
-static char *argv0;
 
 static void
 die(const char *errstr, ...)
 {
         va_list ap;
 
+ fputs("slock: ", stderr);
         va_start(ap, errstr);
- fprintf(stderr, "%s: ", argv0);
         vfprintf(stderr, errstr, ap);
         va_end(ap);
         exit(1);
_AT_@ -256,7 +255,7 @@ lockscreen(Display *dpy, int screen)
                 usleep(1000);
         }
         if (!len) {
- fprintf(stderr, "unable to grab mouse pointer for screen %d\n", screen);
+ fprintf(stderr, "slock: unable to grab mouse pointer for screen %d\n", screen);
         } else {
                 for (len = 1000; len; len--) {
                         if (XGrabKeyboard(dpy, lock->root, True, GrabModeAsync, GrabModeAsync, CurrentTime) == GrabSuccess) {
_AT_@ -266,7 +265,7 @@ lockscreen(Display *dpy, int screen)
                         }
                         usleep(1000);
                 }
- fprintf(stderr, "unable to grab keyboard for screen %d\n", screen);
+ fprintf(stderr, "slock: unable to grab keyboard for screen %d\n", screen);
         }
         /* grabbing one of the inputs failed */
         running = 0;
_AT_@ -283,8 +282,6 @@ main(int argc, char **argv)
         Display *dpy;
         int screen;
 
- argv0 = argv[0], argc--, argv++;
-
 #ifdef __linux__
         dontkillme();
 #endif
_AT_@ -317,11 +314,11 @@ main(int argc, char **argv)
                 return 1;
         }
 
- if (argc >= 1 && fork() == 0) {
+ if (argc >= 2 && fork() == 0) {
                 if (dpy)
                         close(ConnectionNumber(dpy));
- execvp(argv[0], argv);
- die("execvp %s failed: %s\n", argv[0], strerror(errno));
+ execvp(argv[1], argv+1);
+ die("execvp %s failed: %s\n", argv[1], strerror(errno));
         }
 
         /* Everything is now blank. Now wait for the correct password. */
Received on Sat Feb 27 2016 - 15:07:48 CET

This archive was generated by hypermail 2.3.0 : Sat Feb 27 2016 - 15:12:12 CET