summaryrefslogtreecommitdiff
path: root/menudriver.c
diff options
context:
space:
mode:
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");