~jamesodhunt/upstart/async-spawn.20140310

« back to all changes in this revision

Viewing changes to init/job_process.h

  • Committer: James Hunt
  • Date: 2014-03-10 15:13:52 UTC
  • Revision ID: james.hunt@ubuntu.com-20140310151352-06mj0njwsgvi0fa0
temporary commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
136
136
 **/
137
137
typedef void (*JobProcessErrorHandler) (Job *job, JobState state, ProcessType process);
138
138
 
139
 
/**
140
 
 * JobProcessHandlerData:
141
 
 *
142
 
 * @job: job,
143
 
 * @required_state: state job is attempting to move to,
144
 
 * @process: current job process,
145
 
 * @error_handler: handler to call if job process cannot be started,
146
 
 * @script: optional script that job should run with,
147
 
 * @shell_fd: file descriptor attached to child that @script should be
148
 
 * written to (or -1 when @script is NULL).
149
 
 **/
150
 
typedef struct job_process_handler_data {
151
 
        Job                    *job;
152
 
        JobState                required_state;
153
 
        ProcessType             process;
154
 
        JobProcessErrorHandler  error_handler;
155
 
        char                   *script;
156
 
        int                     shell_fd;
157
 
} JobProcessHandlerData;
158
 
 
159
139
NIH_BEGIN_EXTERN
160
140
 
161
141
void
162
142
job_process_start (Job                    *job,
163
143
                   JobState                state,
164
 
                   ProcessType             process,
165
 
                   JobProcessErrorHandler  error_handler);
166
 
 
167
 
void   job_process_run_bottom (Job *job, ProcessType process, const char *script, int shell_fd);
168
 
 
169
 
void   job_process_child_reader (JobProcessHandlerData *handler_data, NihIo *io,
 
144
                   ProcessType             process);
 
145
 
 
146
void   job_process_run_bottom (JobProcessData *handler_data);
 
147
 
 
148
void   job_process_child_reader (JobProcessData *handler_data, NihIo *io,
170
149
                const char *buf, size_t len);
171
150
 
172
 
void   job_process_close_handler (JobProcessHandlerData *handler_data, NihIo *io);
 
151
/* FIXME */
 
152
#if 0
 
153
void   job_process_child_error_handler (JobProcessData *handler_data, NihIo *io);
 
154
#endif
 
155
 
 
156
void   job_process_close_handler (JobProcessData *handler_data, NihIo *io);
173
157
 
174
158
pid_t  job_process_spawn   (Job *job, char * const argv[],
175
159
                            char * const *env, int trace, int script_fd,
196
180
 
197
181
void   job_process_stop_all (void);
198
182
 
 
183
JobProcessData *
 
184
job_process_data_new (void *parent, Job *job, JobState state,
 
185
                ProcessType process, int job_process_fd)
 
186
        __attribute__ ((warn_unused_result));
 
187
 
 
188
json_object *
 
189
job_process_data_serialise (const Job *job, const JobProcessData *handler_data)
 
190
        __attribute__ ((warn_unused_result));
 
191
 
 
192
JobProcessData *
 
193
job_process_data_deserialise (void *parent, Job *job, json_object *json)
 
194
        __attribute__ ((warn_unused_result));
 
195
 
 
196
void job_process_error_handler (const char *buf, size_t len);
 
197
 
199
198
NIH_END_EXTERN
200
199
 
201
200
#endif /* INIT_JOB_PROCESS_H */