On Mon, 10 Jan 2022, Jeremy Drake wrote: > From https://github.com/msys2/MSYS2-packages/issues/2801 > > MSYS2 recently rebuilt GNU make 4.3, and I found that after rebuilding, it > broke rather horribly on i686, where any attempt to run a command resulted > in "Invalid argument" errors. Some debugging revealed that rebuilding > make resulted in it using posix_spawn now instead of vfork. Passing > --disable-posix-spawn to make's configure script results in a working i686 > make. >
> Can you create a simple, self-contained testcase in plain C? Sorry, I am not subscribed to the list so don't have the message to reply to for threading purposes, but attached please find a C reproducer that works on x86_64 but fails on i686. The particular issue seems to be the POSIX_SPAWN_RESETIDS flag - not setting that allows i686 to succeed too.
#include <stdlib.h> #include <stdio.h> #include <string.h> #include <unistd.h> #include <spawn.h> #include <sys/wait.h> extern char **environ; int main() { pid_t pid; char *argv[] = {"sh", "-c", "echo hi", NULL}; posix_spawnattr_t attr; int status; short flags = POSIX_SPAWN_RESETIDS; if ((status = posix_spawnattr_init(&attr)) != 0) { printf("posix_spawnattr_init: %s\n", strerror(status)); return status; } if ((status = posix_spawnattr_setflags(&attr, flags)) != 0) { printf("posix_spawnattr_setflags: %s\n", strerror(status)); return status; } status = posix_spawn(&pid, "/bin/sh", NULL, &attr, argv, environ); if (status == 0) { printf("Child pid: %i\n", pid); do { if (waitpid(pid, &status, 0) != -1) { printf("Child status %d\n", WEXITSTATUS(status)); } else { perror("waitpid"); return 1; } } while (!WIFEXITED(status) && !WIFSIGNALED(status)); } else { printf("posix_spawn: %s\n", strerror(status)); } return status; }
-- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation: https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple