VirtualBox

source: kBuild/vendor/gnumake/current/job.h@ 3140

Last change on this file since 3140 was 3138, checked in by bird, 7 years ago

Imported make 4.2.1 (2e55f5e4abdc0e38c1d64be703b446695e70b3b6) from https://git.savannah.gnu.org/git/make.git.

  • Property svn:eol-style set to native
File size: 5.0 KB
Line 
1/* Definitions for managing subprocesses in GNU Make.
2Copyright (C) 1992-2016 Free Software Foundation, Inc.
3This file is part of GNU Make.
4
5GNU Make is free software; you can redistribute it and/or modify it under the
6terms of the GNU General Public License as published by the Free Software
7Foundation; either version 3 of the License, or (at your option) any later
8version.
9
10GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
11WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License along with
15this program. If not, see <http://www.gnu.org/licenses/>. */
16
17#include "output.h"
18
19#ifdef HAVE_FCNTL_H
20# include <fcntl.h>
21#else
22# include <sys/file.h>
23#endif
24
25/* How to set close-on-exec for a file descriptor. */
26
27#if !defined(F_SETFD) || !defined(F_GETFD)
28# ifdef WINDOWS32
29# define CLOSE_ON_EXEC(_d) process_noinherit(_d)
30# else
31# define CLOSE_ON_EXEC(_d)
32# endif
33#else
34# ifndef FD_CLOEXEC
35# define FD_CLOEXEC 1
36# endif
37# define CLOSE_ON_EXEC(_d) (void) fcntl ((_d), F_SETFD, FD_CLOEXEC)
38#endif
39
40#ifdef NO_OUTPUT_SYNC
41# define RECORD_SYNC_MUTEX(m) \
42 O (error, NILF, \
43 _("-O[TYPE] (--output-sync[=TYPE]) is not configured for this build."));
44#else
45# ifdef WINDOWS32
46/* For emulations in w32/compat/posixfcn.c. */
47# define F_GETFD 1
48# define F_SETLKW 2
49/* Implementation note: None of the values of l_type below can be zero
50 -- they are compared with a static instance of the struct, so zero
51 means unknown/invalid, see w32/compat/posixfcn.c. */
52# define F_WRLCK 1
53# define F_UNLCK 2
54
55struct flock
56 {
57 short l_type;
58 short l_whence;
59 off_t l_start;
60 off_t l_len;
61 pid_t l_pid;
62 };
63
64/* This type is actually a HANDLE, but we want to avoid including
65 windows.h as much as possible. */
66typedef intptr_t sync_handle_t;
67
68/* Public functions emulated/provided in posixfcn.c. */
69int fcntl (intptr_t fd, int cmd, ...);
70intptr_t create_mutex (void);
71int same_stream (FILE *f1, FILE *f2);
72
73# define RECORD_SYNC_MUTEX(m) record_sync_mutex(m)
74void record_sync_mutex (const char *str);
75void prepare_mutex_handle_string (intptr_t hdl);
76# else /* !WINDOWS32 */
77
78typedef int sync_handle_t; /* file descriptor */
79
80# define RECORD_SYNC_MUTEX(m) (void)(m)
81
82# endif
83#endif /* !NO_OUTPUT_SYNC */
84
85/* Structure describing a running or dead child process. */
86
87struct child
88 {
89 struct child *next; /* Link in the chain. */
90
91 struct file *file; /* File being remade. */
92
93 char **environment; /* Environment for commands. */
94 char *sh_batch_file; /* Script file for shell commands */
95 char **command_lines; /* Array of variable-expanded cmd lines. */
96 char *command_ptr; /* Ptr into command_lines[command_line]. */
97
98#ifdef VMS
99 char *comname; /* Temporary command file name */
100 int efn; /* Completion event flag number */
101 int cstatus; /* Completion status */
102 int vms_launch_status; /* non-zero if lib$spawn, etc failed */
103#endif
104
105 unsigned int command_line; /* Index into command_lines. */
106 struct output output; /* Output for this child. */
107 pid_t pid; /* Child process's ID number. */
108 unsigned int remote:1; /* Nonzero if executing remotely. */
109 unsigned int noerror:1; /* Nonzero if commands contained a '-'. */
110 unsigned int good_stdin:1; /* Nonzero if this child has a good stdin. */
111 unsigned int deleted:1; /* Nonzero if targets have been deleted. */
112 unsigned int recursive:1; /* Nonzero for recursive command ('+' etc.) */
113 unsigned int dontcare:1; /* Saved dontcare flag. */
114 };
115
116extern struct child *children;
117
118/* A signal handler for SIGCHLD, if needed. */
119RETSIGTYPE child_handler (int sig);
120int is_bourne_compatible_shell(const char *path);
121void new_job (struct file *file);
122void reap_children (int block, int err);
123void start_waiting_jobs (void);
124
125char **construct_command_argv (char *line, char **restp, struct file *file,
126 int cmd_flags, char** batch_file);
127
128#ifdef VMS
129int child_execute_job (struct child *child, char *argv);
130#else
131# define FD_STDIN (fileno (stdin))
132# define FD_STDOUT (fileno (stdout))
133# define FD_STDERR (fileno (stderr))
134int child_execute_job (struct output *out, int good_stdin, char **argv, char **envp);
135#endif
136
137#ifdef _AMIGA
138void exec_command (char **argv) __attribute__ ((noreturn));
139#elif defined(__EMX__)
140int exec_command (char **argv, char **envp);
141#else
142void exec_command (char **argv, char **envp) __attribute__ ((noreturn));
143#endif
144
145extern unsigned int job_slots_used;
146
147void block_sigs (void);
148#ifdef POSIX
149void unblock_sigs (void);
150#else
151#ifdef HAVE_SIGSETMASK
152extern int fatal_signal_mask;
153#define unblock_sigs() sigsetmask (0)
154#else
155#define unblock_sigs()
156#endif
157#endif
158
159extern unsigned int jobserver_tokens;
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette