mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-01-31 11:37:35 +00:00
3f26dfbb31
This is a breaking change. It defines the new environment variable named _COSMO_FDS_V2 which is used for inheriting non-stdio file descriptors on execve() or posix_spawn(). No effort has been spent thus far integrating with the older variable. If a new binary launches the older ones or vice versa they'll only be able to pass stdin / stdout / stderr to each other therefore it's important that you upgrade all your cosmo binaries if you depend on this functionality. You'll be glad you did because inheritance of file descriptors is more aligned with the POSIX standard than before.
55 lines
1.2 KiB
C
55 lines
1.2 KiB
C
#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_FD_INTERNAL_H_
|
|
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_FD_INTERNAL_H_
|
|
#include "libc/thread/thread.h"
|
|
COSMOPOLITAN_C_START_
|
|
|
|
#define kFdEmpty 0
|
|
#define kFdFile 1
|
|
#define kFdSocket 2
|
|
#define kFdConsole 4
|
|
#define kFdSerial 5
|
|
#define kFdZip 6
|
|
#define kFdEpoll 7
|
|
#define kFdReserved 8
|
|
#define kFdDevNull 9
|
|
#define kFdDevRandom 10
|
|
|
|
struct CursorShared {
|
|
pthread_mutex_t lock;
|
|
long pointer;
|
|
};
|
|
|
|
struct Cursor {
|
|
struct CursorShared *shared;
|
|
_Atomic(int) refs;
|
|
};
|
|
|
|
struct Fd {
|
|
char kind;
|
|
bool isbound;
|
|
unsigned flags;
|
|
unsigned mode;
|
|
long handle;
|
|
int family;
|
|
int type;
|
|
int protocol;
|
|
unsigned rcvtimeo; /* millis; 0 means wait forever */
|
|
unsigned sndtimeo; /* millis; 0 means wait forever */
|
|
void *connect_op;
|
|
struct Cursor *cursor;
|
|
};
|
|
|
|
struct Fds {
|
|
_Atomic(int) f; /* lowest free slot */
|
|
size_t n;
|
|
struct Fd *p, *e;
|
|
};
|
|
|
|
struct Cursor *__cursor_new(void);
|
|
void __cursor_ref(struct Cursor *);
|
|
int __cursor_unref(struct Cursor *);
|
|
void __cursor_lock(struct Cursor *);
|
|
void __cursor_unlock(struct Cursor *);
|
|
|
|
COSMOPOLITAN_C_END_
|
|
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_FD_INTERNAL_H_ */
|