summaryrefslogtreecommitdiff
path: root/menudriver.c
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2022-03-27 22:11:27 -0400
committerJakob Kaivo <jkk@ung.org>2022-03-27 22:11:27 -0400
commit435d1aeca82f2ae9736511951bbe48d212f30d1e (patch)
treefe7e54e88b598b51b8c7d8fced1f34426367113d /menudriver.c
parent666b4b2f60b16a41e9fac985daa1a32752ee30e2 (diff)
use PATH_MAX instead of arbitrary pnlim of 1024
Diffstat (limited to 'menudriver.c')
-rw-r--r--menudriver.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/menudriver.c b/menudriver.c
index 51a1ed9..c050d1c 100644
--- a/menudriver.c
+++ b/menudriver.c
@@ -9,6 +9,7 @@
* Revised to C11 standard and made 64bit compatible, January 2020 *
*------------------------------------------------------------------------*/
+#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
@@ -16,8 +17,15 @@
#include <unistd.h>
#include <sys/wait.h>
#include <signal.h>
-typedef void (*sighandler)();
-#define pnlim 1024
+
+#ifndef PATH_MAX
+#ifdef _XOPEN_PATH_MAX
+#define PATH_MAX _XOPEN_PATH_MAX
+#else
+#define PATH_MAX _POSIX_PATH_MAX
+#endif
+#endif
+
struct stat buf;
char *menuviewer;
@@ -179,8 +187,8 @@ void menudrive(char *dir)
} /* no pathnames - see below */
if (S_ISDIR(buf.st_mode)) { /* directory */
- char hold[pnlim];
- if (!getcwd(hold, pnlim)) {
+ char hold[PATH_MAX];
+ if (!getcwd(hold, sizeof(hold))) {
fprintf(stderr, "panic: cwd too long\n"), exit(1);
}
@@ -333,7 +341,6 @@ void singleton(char *fil)
void callshell(char v[])
{
static char *shell = NULL;
- sighandler oldsig;
int pid;
if (!shell) {
@@ -343,7 +350,7 @@ void callshell(char v[])
}
}
- oldsig = signal(SIGINT, SIG_IGN);
+ void (*oldsig)(int) = signal(SIGINT, SIG_IGN);
if ((pid = fork())) { /* parent */
if (pid == -1) {
perror("UNIX error - cannot create process");