77 lines
2.1 KiB
Diff
77 lines
2.1 KiB
Diff
|
|
From 2a1131169b102a72f0172b4027aa8931093ac551 Mon Sep 17 00:00:00 2001
|
|||
|
|
From: Ken Stailey <kstailey@yahoo.com>
|
|||
|
|
Date: Fri, 27 May 2011 15:10:22 -0400
|
|||
|
|
Subject: [PATCH 1/2] Improved subprocess
|
|||
|
|
MIME-Version: 1.0
|
|||
|
|
Content-Type: text/plain; charset=UTF-8
|
|||
|
|
Content-Transfer-Encoding: 8bit
|
|||
|
|
|
|||
|
|
Patch author: Anders Kaseorg
|
|||
|
|
Patch E-mail list URLs:
|
|||
|
|
http://lists.askja.de/pipermail/ldapvi/2010-December/000085.html
|
|||
|
|
http://lists.askja.de/pipermail/ldapvi/2010-December/000086.html
|
|||
|
|
|
|||
|
|
From exec(3): “The list of arguments must be terminated by a NULL
|
|||
|
|
pointer, and, since these are variadic functions, this pointer must be
|
|||
|
|
cast (char *) NULL.”
|
|||
|
|
|
|||
|
|
This prevents crashes on 64-bit systems, where 0 is a 32-bit integer
|
|||
|
|
and (char *) NULL is a 64-bit pointer.
|
|||
|
|
|
|||
|
|
Previously when the EDITOR environment variable is set to a command
|
|||
|
|
with arguments, such as ‘emacsclient --alternate-editor emacs’, ldapvi
|
|||
|
|
would fail to launch the editor:
|
|||
|
|
|
|||
|
|
$ ldapvi
|
|||
|
|
26 entries read
|
|||
|
|
error (misc.c line 180): No such file or directory
|
|||
|
|
editor died
|
|||
|
|
error (ldapvi.c line 83): No such file or directory
|
|||
|
|
|
|||
|
|
Also setting PAGER to "less -s" or similar had the same effects
|
|||
|
|
when you use Action? (v) view LDIF changes or other commands
|
|||
|
|
that invoke $PAGER.
|
|||
|
|
---
|
|||
|
|
ldapvi/misc.c | 10 ++++++----
|
|||
|
|
1 files changed, 6 insertions(+), 4 deletions(-)
|
|||
|
|
|
|||
|
|
diff --git a/ldapvi/misc.c b/ldapvi/misc.c
|
|||
|
|
index 3b6896e..2e3a1f5 100644
|
|||
|
|
--- a/ldapvi/misc.c
|
|||
|
|
+++ b/ldapvi/misc.c
|
|||
|
|
@@ -172,9 +172,11 @@ edit(char *pathname, long line)
|
|||
|
|
if (line > 0) {
|
|||
|
|
char buf[20];
|
|||
|
|
snprintf(buf, 20, "+%ld", line);
|
|||
|
|
- execlp(vi, vi, buf, pathname, 0);
|
|||
|
|
+ execl("/bin/sh", "sh", "-c", "exec $0 \"$@\"", vi,
|
|||
|
|
+ buf, pathname, (char *) NULL);
|
|||
|
|
} else
|
|||
|
|
- execlp(vi, vi, pathname, 0);
|
|||
|
|
+ execl("/bin/sh", "sh", "-c", "exec $0 \"$@\"", vi,
|
|||
|
|
+ pathname, (char *) NULL);
|
|||
|
|
syserr();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
@@ -213,7 +215,7 @@ view(char *pathname)
|
|||
|
|
case -1:
|
|||
|
|
syserr();
|
|||
|
|
case 0:
|
|||
|
|
- execlp(pg, pg, pathname, 0);
|
|||
|
|
+ execlp(pg, pg, pathname, (char *) NULL);
|
|||
|
|
syserr();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
@@ -245,7 +247,7 @@ pipeview(int *fd)
|
|||
|
|
close(fds[1]);
|
|||
|
|
dup2(fds[0], 0);
|
|||
|
|
close(fds[0]);
|
|||
|
|
- execlp(pg, pg, 0);
|
|||
|
|
+ execlp(pg, pg, (char *) NULL);
|
|||
|
|
syserr();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
--
|
|||
|
|
1.7.6
|
|||
|
|
|