Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion file_cmds/cksum/cksum.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ chksum_main(int argc, char **argv)
rval = 1;
} else
pfncn(fn, val, len);
(void)close(fd);
if (fn != NULL)
(void)close(fd);
} while (*argv);
exit(rval);
}
Expand Down
2 changes: 1 addition & 1 deletion file_cmds/gzip/gzip.c
Original file line number Diff line number Diff line change
Expand Up @@ -1355,7 +1355,7 @@ file_compress(char *file, char *outfile, size_t outsize)
out = open(outfile, O_WRONLY | O_CREAT | O_EXCL, 0600);
if (out == -1) {
maybe_warn("could not create output: %s", outfile);
fclose(thread_stdin);
close(in);
return (-1);
}
#ifndef SMALL
Expand Down
2 changes: 2 additions & 0 deletions ios_error.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ extern int ios_killpid(pid_t pid, int sig); // kill the current running command

extern void ios_exit(int errorCode) __dead2; // set error code and exits from the thread.
extern int ios_execv(const char *path, char* const argv[]);
extern int ios_execv_async(const char *path, char* const argv[]); // returns once the child has started
extern int ios_pidStatus(pid_t pid); // exit status of a finished virtual pid, -1 if unknown
extern int ios_execve(const char *path, char* const argv[], char** envlist);
extern int ios_dup2(int fd1, int fd2);
extern char * ios_getenv(const char *name);
Expand Down
31 changes: 31 additions & 0 deletions ios_spawn.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#ifndef IOS_SPAWN_H
#define IOS_SPAWN_H
#include <sys/types.h>
#include <stddef.h>
#include <sys/resource.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Isolated worker processes inherit only stdin, stdout and stderr. */
typedef struct { int source, target; } ios_spawn_action;
typedef struct {
ios_spawn_action *actions;
size_t count;
char *cwd;
} ios_posix_spawn_file_actions_t;
int ios_posix_spawn_file_actions_init(ios_posix_spawn_file_actions_t *);
int ios_posix_spawn_file_actions_destroy(ios_posix_spawn_file_actions_t *);
int ios_posix_spawn_file_actions_adddup2(ios_posix_spawn_file_actions_t *, int, int);
int ios_posix_spawn_file_actions_addclose(ios_posix_spawn_file_actions_t *, int);
int ios_posix_spawn_file_actions_addchdir_np(ios_posix_spawn_file_actions_t *, const char *);
int ios_posix_spawn(pid_t *, const char *, const ios_posix_spawn_file_actions_t *, const void *, char *const [], char *const []);
/* Wait for an ios_posix_spawn PID; options is 0 or WNOHANG. Returns PID, 0 while
* running, or -1 with errno. Status uses waitpid encoding (ios_killpid with SIGINT, SIGTERM, SIGKILL, SIGHUP or SIGQUIT: exit 128 + signal; worker transport failure: exit 125).
* Optional usage is the isolated worker's RUSAGE_SELF snapshot at command exit,
* including process startup. availability is required when usage is requested;
* zero means unavailable (including cancellation), never a measured zero. */
pid_t ios_wait4(pid_t, int *, int, struct rusage *, int *availability);
#ifdef __cplusplus
}
#endif
#endif
Loading
Loading