/me back from vacation
I'll look at it and forward to glibc maintainers
On 07/05/2012 07:46 PM, Irek Szczesniak wrote:
On Wed, Jul 4, 2012 at 8:34 PM, Irek Szczesniak <iszczesn...@gmail.com> wrote:
On Wed, Jul 4, 2012 at 7:32 PM, ольга крыжановская
<olga.kryzhanov...@gmail.com> wrote:
Michael or any other Linux guru, can you look why ksh (2012-06-28, the
non doomsday release) no longer uses posix_spawn?
I am getting this line when I build ksh on Fedora:
iffe: test: posix_spawn exists and it works and its worth using ... no
This doesn't sound right, IMO ksh should prefer (and benefit) from
using posix_spawn()
This is interesting. I thought both Linux and Solaris use
posix_spawn() to avoid the much more expensive vfork()/exec().
I've disassembled Glenn's test. If I got it right then we see a bug in glibc:
==========================
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <spawn.h>
#include <signal.h>
#include <fcntl.h>
#include <string.h>
#include <stdio.h>
int
main(int argc, char** argv)
{
char* s;
pid_t pid;
posix_spawnattr_t attr;
int n;
int status;
char* cmd[3];
char tmp[1024];
if (argv[1])
_exit(signal(SIGHUP, SIG_DFL) != SIG_IGN);
signal(SIGHUP, SIG_IGN);
if (posix_spawnattr_init(&attr))
{
fprintf(stderr, "# posix_spawnattr_init failed.\n");
_exit(0);
}
if (posix_spawnattr_setpgroup(&attr, 0))
{
fprintf(stderr, "# posix_spawnattr_setpgroup failed.\n");
_exit(0);
}
if (posix_spawnattr_setflags(&attr, POSIX_SPAWN_SETPGROUP))
{
fprintf(stderr, "# posix_spawnattr_setflags failed.\n");
_exit(0);
}
/* first try an a.out and verify that SIGHUP is ignored */
cmd[0] = argv[0];
cmd[1] = "test";
cmd[2] = 0;
if (posix_spawn(&pid, cmd[0], 0, &attr, cmd, 0))
{
fprintf(stderr, "# posix_spawn failed.\n");
_exit(0);
}
status = 1;
if (wait(&status) < 0 || status != 0)
{
fprintf(stderr, "# wait failed.\n");
_exit(0);
}
/* passing ENOEXEC to the shell is bogus */
n = strlen(cmd[0]);
if (n >= (sizeof(tmp) - 3))
{
fprintf(stderr, "# bogus ENOEXEC.\n");
_exit(0);
}
strcpy(tmp, cmd[0]);
tmp[n] = '.';
tmp[n+1] = 's';
tmp[n+2] = 'h';
tmp[n+3] = 0;
if (close(open(tmp, O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO)) < 0 ||
chmod(tmp, S_IRWXU|S_IRWXG|S_IRWXO) < 0)
{
fprintf(stderr, "# close() failed.\n");
_exit(0);
}
cmd[0] = tmp;
n = 0;
pid = -1;
if (posix_spawn(&pid, cmd[0], 0, &attr, cmd, 0))
n = 2;
else
{
n = pid != -1 && waitpid(pid, &status, WNOHANG|WNOWAIT) == pid
&&
((status>>8)&0x7f) == 127;
wait(&status);
fprintf(stderr, "# posix_spawn() did not fail as expected,
waitpid
status %d, pid=%d.\n", n, pid);
}
_exit(n);
}
==========================
On both Fedora and Suse I get:
./pstest
# posix_spawn() did not fail as expected, waitpid status 0, pid=3080.
Pretty much a POSIX conformance issue which need to be passed to
Fedora and Suse upstream.
Irek
_______________________________________________
ast-developers mailing list
ast-developers@research.att.com
https://mailman.research.att.com/mailman/listinfo/ast-developers