blob: b6f517984e9512c04203b7b230fa521a8dda480c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
/* ISC license. */
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
#include <spawn.h>
int main (void)
{
posix_spawnattr_t attr ;
int e ;
char tmp[40] = "./tryposixspawnearlyreturn child:XXXXXX" ;
char *argv[2] = { tmp, 0 } ;
char *env = 0 ;
int fd = mkstemp(tmp) ;
if (fd == -1) return 111 ;
e = posix_spawnattr_init(&attr) ;
if (e) return 111 ;
e = posix_spawnattr_setflags(&attr, 0) ;
if (e) return 111 ;
if (close(fd) == -1 || unlink(tmp) == -1) return 111 ;
e = posix_spawn(0, argv[0], 0, &attr, argv, &env) ;
return e ? e == ENOENT ? 1 : 111 : 0 ;
}
|