From 4cf8f2098f227d32f3b73c70a6498c84872c24ba Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Thu, 10 Jan 2013 14:14:55 -0800 Subject: Support run tst-exec and tst-spawn directly --- posix/tst-spawn.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) (limited to 'posix/tst-spawn.c') diff --git a/posix/tst-spawn.c b/posix/tst-spawn.c index 718602e..66fd26b 100644 --- a/posix/tst-spawn.c +++ b/posix/tst-spawn.c @@ -169,12 +169,13 @@ do_test (int argc, char *argv[]) char fd3name[18]; char fd4name[18]; char *spargv[12]; + int i; /* We must have - - four parameters left of called initially - + path for ld.so - + "--library-path" - + the library path + - one or four parameters left if called initially + + path for ld.so optional + + "--library-path" optional + + the library path optional + the application name - five parameters left if called through re-execution + file descriptor number which is supposed to be closed @@ -183,7 +184,7 @@ do_test (int argc, char *argv[]) + thhe duped second descriptor + the name of the closed descriptor */ - if (argc != (restart ? 6 : 5)) + if (argc != (restart ? 6 : 2) && argc != (restart ? 6 : 5)) error (EXIT_FAILURE, 0, "wrong number of arguments (%d)", argc); if (restart) @@ -235,18 +236,16 @@ do_test (int argc, char *argv[]) snprintf (fd3name, sizeof fd3name, "%d", fd3); snprintf (fd4name, sizeof fd4name, "%d", fd4); - spargv[0] = argv[1]; - spargv[1] = argv[2]; - spargv[2] = argv[3]; - spargv[3] = argv[4]; - spargv[4] = (char *) "--direct"; - spargv[5] = (char *) "--restart"; - spargv[6] = fd1name; - spargv[7] = fd2name; - spargv[8] = fd3name; - spargv[9] = fd4name; - spargv[10] = name1; - spargv[11] = NULL; + for (i = 0; i < (argc == (restart ? 6 : 5) ? 4 : 1); i++) + spargv[i] = argv[i + 1]; + spargv[i++] = (char *) "--direct"; + spargv[i++] = (char *) "--restart"; + spargv[i++] = fd1name; + spargv[i++] = fd2name; + spargv[i++] = fd3name; + spargv[i++] = fd4name; + spargv[i++] = name1; + spargv[i] = NULL; if (posix_spawn (&pid, argv[1], &actions, NULL, spargv, environ) != 0) error (EXIT_FAILURE, errno, "posix_spawn"); -- cgit v1.1