2016-04-29 02:41:54 +00:00
|
|
|
// Prototypes for functions for executing a program.
|
2005-10-04 15:11:39 +00:00
|
|
|
#ifndef FISH_EXEC_H
|
|
|
|
#define FISH_EXEC_H
|
|
|
|
|
2015-07-25 15:14:25 +00:00
|
|
|
#include <stddef.h>
|
2017-02-14 04:37:27 +00:00
|
|
|
|
2011-12-27 03:18:46 +00:00
|
|
|
#include <vector>
|
2005-10-04 15:11:39 +00:00
|
|
|
|
2011-12-27 03:18:46 +00:00
|
|
|
#include "common.h"
|
2020-01-30 00:39:44 +00:00
|
|
|
#include "proc.h"
|
2005-10-04 15:11:39 +00:00
|
|
|
|
2016-04-29 02:41:54 +00:00
|
|
|
/// Pipe redirection error message.
|
2006-01-04 12:51:02 +00:00
|
|
|
#define PIPE_ERROR _(L"An error occurred while setting up pipe")
|
2005-10-08 11:20:51 +00:00
|
|
|
|
2018-11-04 07:58:44 +00:00
|
|
|
/// Execute the processes specified by \p j in the parser \p.
|
2019-12-27 05:54:21 +00:00
|
|
|
bool exec_job(parser_t &parser, const std::shared_ptr<job_t> &j, const job_lineage_t &lineage);
|
2005-09-20 13:26:39 +00:00
|
|
|
|
2020-01-24 01:34:46 +00:00
|
|
|
/// Evaluate a command.
|
2016-04-29 02:41:54 +00:00
|
|
|
///
|
|
|
|
/// \param cmd the command to execute
|
2020-01-24 01:34:46 +00:00
|
|
|
/// \param parser the parser with which to execute code
|
|
|
|
/// \param outputs the list to insert output into.
|
|
|
|
/// \param apply_exit_status if set, update $status within the parser, otherwise do not.
|
2016-04-29 02:41:54 +00:00
|
|
|
///
|
2020-01-24 01:34:46 +00:00
|
|
|
/// \return a value appropriate for populating $status.
|
|
|
|
int exec_subshell(const wcstring &cmd, parser_t &parser, bool apply_exit_status);
|
2019-03-14 18:15:50 +00:00
|
|
|
int exec_subshell(const wcstring &cmd, parser_t &parser, wcstring_list_t &outputs,
|
2020-01-24 01:34:46 +00:00
|
|
|
bool apply_exit_status);
|
|
|
|
|
|
|
|
/// Like exec_subshell, but only returns expansion-breaking errors. That is, a zero return means
|
|
|
|
/// "success" (even though the command may have failed), a non-zero return means that we should
|
2020-03-11 18:06:52 +00:00
|
|
|
/// halt expansion. If the \p pgid is supplied, then any spawned external commands should join that
|
|
|
|
/// pgroup.
|
|
|
|
int exec_subshell_for_expand(const wcstring &cmd, parser_t &parser, maybe_t<pid_t> parent_pgid,
|
|
|
|
wcstring_list_t &outputs);
|
2011-12-27 03:18:46 +00:00
|
|
|
|
2016-04-29 02:41:54 +00:00
|
|
|
/// Loops over close until the syscall was run without being interrupted.
|
2012-11-19 00:30:30 +00:00
|
|
|
void exec_close(int fd);
|
2005-09-20 13:26:39 +00:00
|
|
|
|
2020-01-30 00:39:44 +00:00
|
|
|
/// Compute the "pgroup provenance" for a job. This is a description of how the pgroup is
|
|
|
|
/// assigned. It's factored out because the logic has subtleties, and this centralizes it.
|
|
|
|
pgroup_provenance_t get_pgroup_provenance(const std::shared_ptr<job_t> &j,
|
|
|
|
const job_lineage_t &lineage);
|
2020-04-05 08:24:26 +00:00
|
|
|
|
|
|
|
/// Add signals that should be masked for external processes in this job.
|
|
|
|
bool blocked_signals_for_job(const job_t &job, sigset_t *sigmask);
|
|
|
|
|
2005-10-04 15:11:39 +00:00
|
|
|
#endif
|