Skip to content

Commit

Permalink
Implement spawn2ve() and spawn2vpe()
Browse files Browse the repository at this point in the history
This has the following features over spawn2():

1. Split into spawn2ve() which is non-PATH-searching version and
   spawn2vpe() which is PATH-searching version.

2. Pass open file handles without FD_CLOEXEC to a child unless
   P_2_NOINEHRIT is given explicitly.

    modified:   Makefile
    modified:   check.cmd
    new file:   include/os2compat/spawn2.h
    new file:   process/spawn2.c
    new file:   process/spawn2.h
    modified:   testcase/Makefile
    new file:   testcase/spawn2-1.c
    new file:   testcase/spawn2-2.c
  • Loading branch information
komh committed Nov 7, 2024
1 parent f973053 commit 95badf1
Show file tree
Hide file tree
Showing 8 changed files with 689 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ HEADER_FILES := include/os2compat/dirent.h \
include/os2compat/poll.h \
include/os2compat/semaphore.h \
include/os2compat/sched.h \
include/os2compat/spawn2.h \
include/os2compat/net/if.h \
include/os2compat/sys/mman.h \
include/os2compat/sys/socket.h \
Expand All @@ -192,6 +193,7 @@ PRIV_HEADER_FILES := io/scandir.h \
network/shutdown.h \
network/socklen_t.h \
network/xpoll.h \
process/spawn2.h \
thread/semaphore.h \
thread/sched_yield.h

Expand Down
5 changes: 5 additions & 0 deletions check.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ call checkCC 'network/getifaddrs.h', 'network/getifaddrs.c', ,
'struct ifaddrs *ifa;' || g.sNl ||,
'getifaddrs( &ifa );' || g.sNl ||,
'freeifaddrs( ifa );';
call checkCC 'process/spawn2.h', 'process/spawn2.c', ,
'spawn2ve( 0, 0, 0, 0, 0, 0 );' || g.sNl ||,
'spawn2vpe( 0, 0, 0, 0, 0, 0 );';

call checkOS2CompatHeader;

Expand Down Expand Up @@ -133,6 +136,7 @@ checkOS2CompatHeader: procedure expose G.
'include/os2compat/poll.h',
'include/os2compat/semaphore.h',
'include/os2compat/sched.h',
'include/os2compat/spawn2.h',
'include/os2compat/net/if.h',
'include/os2compat/sys/mman.h',
'include/os2compat/sys/socket.h',
Expand All @@ -147,6 +151,7 @@ checkOS2CompatHeader: procedure expose G.
'network/shutdown.h',
'network/socklen_t.h',
'network/xpoll.h',
'process/spawn2.h',
'thread/semaphore.h',
'thread/sched_yield.h';
sDestDir = 'include/os2compat/priv';
Expand Down
18 changes: 18 additions & 0 deletions include/os2compat/spawn2.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* spawn2.h for os2compat
*
* Copyright (C) 2024 KO Myung-Hun <[email protected]>
*
* This program is free software. It comes without any warranty, to
* the extent permitted by applicable law. You can redistribute it
* and/or modify it under the terms of the Do What The Fuck You Want
* To Public License, Version 2, as published by Sam Hocevar. See
* http://www.wtfpl.net/ for more details.
*/

#ifndef OS2COMPAT_INCLUDE_SPAWN2_H
#define OS2COMPAT_INCLUDE_SPAWN2_H

#include "priv/process/spawn2.h"

#endif
Loading

0 comments on commit 95badf1

Please sign in to comment.