Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 2229e55

Browse files
committed
Fix posix_spawn()/posix_spawnp() nullability annotations.
argv is terminated by a null pointer, so that was clearly a mistake. Linux actually allows argv itself to be a null pointer, though that's not portable and even Linux calls pr_warn_once() if you take advantage of this, so we might want to remove that _Nullable from all the exec()-like functions, but for now let's just make sure everything's consistent and not _wrong_... We can worry about not enabling bad practices later (or not, since this isn't something I've ever seen anyone do). Change-Id: I633245085ca960e6e7b73d4a8aeb4c0535034cef
1 parent d471b7a commit 2229e55

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

libc/include/spawn.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,17 @@ __BEGIN_DECLS
4646
#define POSIX_SPAWN_USEVFORK 64
4747
#define POSIX_SPAWN_SETSID 128
4848
#endif
49-
// mark all fds (except stdin/out/err) as close-on-exec prior to executing registered file actions
49+
/**
50+
* Used with posix_spawnattr_setflags() to mark all fds except
51+
* stdin/stdout/stderr as O_CLOEXEC prior to executing registered file actions.
52+
*/
5053
#define POSIX_SPAWN_CLOEXEC_DEFAULT 256
5154

5255
typedef struct __posix_spawnattr* posix_spawnattr_t;
5356
typedef struct __posix_spawn_file_actions* posix_spawn_file_actions_t;
5457

55-
int posix_spawn(pid_t* _Nullable __pid, const char* _Nonnull __path, const posix_spawn_file_actions_t _Nullable * _Nullable __actions, const posix_spawnattr_t _Nullable * _Nullable __attr, char* const _Nonnull __argv[_Nonnull], char* const _Nullable __env[_Nullable]) __INTRODUCED_IN(28);
56-
int posix_spawnp(pid_t* _Nullable __pid, const char* _Nonnull __file, const posix_spawn_file_actions_t _Nullable * _Nullable __actions, const posix_spawnattr_t _Nullable * _Nullable __attr, char* const _Nonnull __argv[_Nonnull], char* const _Nullable __env[_Nullable]) __INTRODUCED_IN(28);
58+
int posix_spawn(pid_t* _Nullable __pid, const char* _Nonnull __path, const posix_spawn_file_actions_t _Nullable * _Nullable __actions, const posix_spawnattr_t _Nullable * _Nullable __attr, char* const _Nullable __argv[_Nullable], char* const _Nullable __env[_Nullable]) __INTRODUCED_IN(28);
59+
int posix_spawnp(pid_t* _Nullable __pid, const char* _Nonnull __file, const posix_spawn_file_actions_t _Nullable * _Nullable __actions, const posix_spawnattr_t _Nullable * _Nullable __attr, char* const _Nullable __argv[_Nullable], char* const _Nullable __env[_Nullable]) __INTRODUCED_IN(28);
5760

5861
int posix_spawnattr_init(posix_spawnattr_t _Nullable * _Nonnull __attr) __INTRODUCED_IN(28);
5962
int posix_spawnattr_destroy(posix_spawnattr_t _Nonnull * _Nonnull __attr) __INTRODUCED_IN(28);

0 commit comments

Comments
 (0)