File bug.cpp of Package bug

#include <cstring>
#include <iostream>

#include <spawn.h>
#include <unistd.h>
#include <sys/wait.h>

int main(int, char **argv)
{
	extern char **environ;
	const char *const aa[] = {
		"/does_not_exist/bin",
		nullptr
	};
	pid_t pid;
	errno = 0;
	auto ret = posix_spawn(&pid, aa[0], nullptr, nullptr,
			       const_cast<char *const *>(aa),
			       environ);
	int stat = 0;
	if (!ret)
		waitpid(pid, &stat, 0);
	std::cerr << "spawn=" << ret << " stat=" << WEXITSTATUS(stat) <<
		" errno=" << errno << " (" << strerror(errno) << ')' << '\n';
	return 1;
}
openSUSE Build Service is sponsored by