I run it without problem.

SLES7, LPAR, kernel 2.4.7-6 (6th patch from IBM)


WBR, Sergey



                    "Ferguson, Neale"
                    <Neale.Ferguson@SoftwareA        To:     [EMAIL PROTECTED]
                    G-USA.com>                       cc:
                    Sent by: Linux on 390            Subject:     posix_spawn & wait
                    Port
                    <[EMAIL PROTECTED]>


                    01.05.02 22:19
                    Please respond to Linux
                    on 390 Port






For those who are so inclined I'd be interested to see what you get
when you compile and run the following "testspawn.c":

#include <stdio.h>
#include <spawn.h>

int
main(int argc, char **argv)
{
 char *prog = "ls";
 pid_t pid;
 int fdmap[3];
 extern char **environ;
 int status;
 posix_spawn_file_actions_t pFaction;

 posix_spawn_file_actions_init(&pFaction);
 posix_spawn_file_actions_adddup2(&pFaction, 0, 0);
 posix_spawn_file_actions_adddup2(&pFaction, 1, 1);
 posix_spawn_file_actions_adddup2(&pFaction, 2, 2);
 if (posix_spawnp(&pid, prog, &pFaction, NULL, 0, environ) != -1)
       waitpid(pid, &status, 1);
 else
       perror("posix_spawn");
 posix_spawn_file_actions_destroy(&pFaction);
}

I hang on the waitpid. However, if I invoke it using: strace ./testspawn.
It completes without error. Same if I used gdb.

If I change it to waitpid(pid, &status, 0); it also works properly.

If you do it, please tell me: kernel level, glibc level, and distribution.

When doing a comparison for fork/exec versus posix_spawn I see the later is
about 10% more expensive. I must admit I preferred the semantics of the
spawn() API as implemented in VM Open Extensions where the file_actions was
a simple integer array.

Neale

Reply via email to