}
static int do_execute(
- const char* const* directories,
+ char* const* paths,
usec_t timeout,
gather_stdout_callback_t const callbacks[_STDOUT_CONSUME_MAX],
void* const callback_args[_STDOUT_CONSUME_MAX],
ExecDirFlags flags) {
_cleanup_hashmap_free_free_ Hashmap *pids = NULL;
- _cleanup_strv_free_ char **paths = NULL;
- int r;
bool parallel_execution;
+ int r;
/* We fork this all off from a child process so that we can somewhat cleanly make
* use of SIGALRM to set a time limit.
*/
parallel_execution = FLAGS_SET(flags, EXEC_DIR_PARALLEL) && !callbacks;
- r = conf_files_list_strv(&paths, NULL, NULL, CONF_FILES_EXECUTABLE|CONF_FILES_REGULAR|CONF_FILES_FILTER_MASKED, directories);
- if (r < 0)
- return log_error_errno(r, "Failed to enumerate executables: %m");
-
if (parallel_execution) {
pids = hashmap_new(NULL);
if (!pids)
char *envp[],
ExecDirFlags flags) {
+ _cleanup_strv_free_ char **paths = NULL;
_cleanup_close_ int fd = -EBADF;
- int r;
pid_t executor_pid;
+ int r;
+
+ r = conf_files_list_strv(&paths, NULL, NULL, CONF_FILES_EXECUTABLE|CONF_FILES_REGULAR|CONF_FILES_FILTER_MASKED, directories);
+ if (r < 0)
+ return log_error_errno(r, "Failed to enumerate executables: %m");
- assert(!strv_isempty((char**) directories));
+ if (strv_isempty(paths)) {
+ log_debug("No executables found.");
+ return 0;
+ }
if (callbacks) {
assert(callback_args);
if (r < 0)
return r;
if (r == 0) {
- r = do_execute(directories, timeout, callbacks, callback_args, fd, argv, envp, flags);
+ r = do_execute(paths, timeout, callbacks, callback_args, fd, argv, envp, flags);
_exit(r < 0 ? EXIT_FAILURE : r);
}