Skip to content

Instantly share code, notes, and snippets.

@weltling
Created February 2, 2016 10:23
Show Gist options
  • Save weltling/231b26fc76ab79f546c3 to your computer and use it in GitHub Desktop.
Save weltling/231b26fc76ab79f546c3 to your computer and use it in GitHub Desktop.
diff --git a/ext/standard/exec.c b/ext/standard/exec.c
index 461bef4..d15c8a0 100644
--- a/ext/standard/exec.c
+++ b/ext/standard/exec.c
@@ -50,6 +50,10 @@
#include <unistd.h>
#endif
+#if HAVE_LIMITS_H
+#include <limits.h>
+#endif
+
#ifdef PHP_WIN32
# include "win32/php_stdint.h"
#else
@@ -67,6 +71,13 @@ PHP_MINIT_FUNCTION(exec)
{
#ifdef _SC_ARG_MAX
cmd_max_len = sysconf(_SC_ARG_MAX);
+ if (-1 == cmd_max_len) {
+#ifdef _POSIX_ARG_MAX
+ cmd_max_len = _POSIX_ARG_MAX;
+#else
+ cmd_max_len = 4096;
+#endif
+ }
#elif defined(ARG_MAX)
cmd_max_len = ARG_MAX;
#elif defined(PHP_WIN32)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment