2 Copyright (C) 2020-2024 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3, or (at your option)
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, see <https://www.gnu.org/licenses/>. */
17 /* Written by Bruno Haible <bruno@clisp.org>, 2020. */
24 #include "signature.h"
25 SIGNATURE_CHECK (execve
, int, (const char *, char * const *, char * const *));
30 /* Looks up the NAME=VALUE assignment among the environment variables.
31 Returns it, or NULL if not found. */
33 get_environ_assignment (const char *name
)
35 size_t name_len
= strlen (name
);
37 for (p
= environ
; *p
!= NULL
; p
++)
39 const char *assignment
= *p
;
40 if (strncmp (assignment
, name
, name_len
) == 0
41 && assignment
[name_len
] == '=')
47 /* Creates a minimal environment. */
49 create_minimal_env (const char *env
[5])
54 /* The Cygwin DLLs needed by the program are in /bin. */
59 *p
= get_environ_assignment ("QEMU_LD_PREFIX");
62 *p
= get_environ_assignment ("QEMU_CPU");
65 *p
++ = "Hommingberg=Gepardenforelle";
72 const char *progname
= "./test-exec-child";
73 const char *argv
[12] =
89 create_minimal_env (env
);
90 execve (progname
, (char * const *) argv
, (char * const *) env
);