Lines Matching refs:spawn

571         Spawn *spawn = userdata;  in on_spawn_io()  local
577 assert(spawn); in on_spawn_io()
578 assert(fd == spawn->fd_stdout || fd == spawn->fd_stderr); in on_spawn_io()
579 assert(!spawn->result || spawn->result_len < spawn->result_size); in on_spawn_io()
581 if (fd == spawn->fd_stdout && spawn->result) { in on_spawn_io()
582 p = spawn->result + spawn->result_len; in on_spawn_io()
583 size = spawn->result_size - spawn->result_len; in on_spawn_io()
594 log_device_error_errno(spawn->device, errno, in on_spawn_io()
595 "Failed to read stdout of '%s': %m", spawn->cmd); in on_spawn_io()
601 log_device_warning(spawn->device, "Truncating stdout of '%s' up to %zu byte.", in on_spawn_io()
602 spawn->cmd, spawn->result_size); in on_spawn_io()
604 spawn->truncated = true; in on_spawn_io()
608 if (fd == spawn->fd_stdout && spawn->result) in on_spawn_io()
609 spawn->result_len += l; in on_spawn_io()
612 if (l > 0 && spawn->fd_stderr >= 0) { in on_spawn_io()
617 log_device_debug(spawn->device, in on_spawn_io()
619 spawn->cmd, fd == spawn->fd_stdout ? "out" : "err"); in on_spawn_io()
622 log_device_debug(spawn->device, "'%s'(%s) '%s'", spawn->cmd, in on_spawn_io()
623 fd == spawn->fd_stdout ? "out" : "err", *q); in on_spawn_io()
626 if (l == 0 || spawn->truncated) in on_spawn_io()
634 log_device_error_errno(spawn->device, r, in on_spawn_io()
635 "Failed to reactivate IO source of '%s'", spawn->cmd); in on_spawn_io()
640 Spawn *spawn = userdata; in on_spawn_timeout() local
642 assert(spawn); in on_spawn_timeout()
644 DEVICE_TRACE_POINT(spawn_timeout, spawn->device, spawn->cmd); in on_spawn_timeout()
646 kill_and_sigcont(spawn->pid, spawn->timeout_signal); in on_spawn_timeout()
648 … log_device_error(spawn->device, "Spawned process '%s' ["PID_FMT"] timed out after %s, killing", in on_spawn_timeout()
649 spawn->cmd, spawn->pid, in on_spawn_timeout()
650 FORMAT_TIMESPAN(spawn->timeout_usec, USEC_PER_SEC)); in on_spawn_timeout()
656 Spawn *spawn = userdata; in on_spawn_timeout_warning() local
658 assert(spawn); in on_spawn_timeout_warning()
660 …log_device_warning(spawn->device, "Spawned process '%s' ["PID_FMT"] is taking longer than %s to co… in on_spawn_timeout_warning()
661 spawn->cmd, spawn->pid, in on_spawn_timeout_warning()
662 FORMAT_TIMESPAN(spawn->timeout_warn_usec, USEC_PER_SEC)); in on_spawn_timeout_warning()
668 Spawn *spawn = userdata; in on_spawn_sigchld() local
671 assert(spawn); in on_spawn_sigchld()
676 log_device_debug(spawn->device, "Process '%s' succeeded.", spawn->cmd); in on_spawn_sigchld()
678 … log_device_full(spawn->device, spawn->accept_failure ? LOG_DEBUG : LOG_WARNING, in on_spawn_sigchld()
679 … "Process '%s' failed with exit code %i.", spawn->cmd, si->si_status); in on_spawn_sigchld()
684 …log_device_error(spawn->device, "Process '%s' terminated by signal %s.", spawn->cmd, signal_to_str… in on_spawn_sigchld()
687 … log_device_error(spawn->device, "Process '%s' failed due to unknown reason.", spawn->cmd); in on_spawn_sigchld()
690 DEVICE_TRACE_POINT(spawn_exit, spawn->device, spawn->cmd); in on_spawn_sigchld()
696 static int spawn_wait(Spawn *spawn) { in spawn_wait() argument
703 assert(spawn); in spawn_wait()
707 … return log_device_debug_errno(spawn->device, r, "Failed to allocate sd-event object: %m"); in spawn_wait()
709 if (spawn->timeout_usec > 0) { in spawn_wait()
713 age_usec = usec - spawn->event_birth_usec; in spawn_wait()
714 if (age_usec < spawn->timeout_usec) { in spawn_wait()
715 if (spawn->timeout_warn_usec > 0 && in spawn_wait()
716 spawn->timeout_warn_usec < spawn->timeout_usec && in spawn_wait()
717 spawn->timeout_warn_usec > age_usec) { in spawn_wait()
718 spawn->timeout_warn_usec -= age_usec; in spawn_wait()
721 usec + spawn->timeout_warn_usec, USEC_PER_SEC, in spawn_wait()
722 on_spawn_timeout_warning, spawn); in spawn_wait()
724 …return log_device_debug_errno(spawn->device, r, "Failed to create timeout warning event source: %m… in spawn_wait()
727 spawn->timeout_usec -= age_usec; in spawn_wait()
730 … usec + spawn->timeout_usec, USEC_PER_SEC, on_spawn_timeout, spawn); in spawn_wait()
732 … return log_device_debug_errno(spawn->device, r, "Failed to create timeout event source: %m"); in spawn_wait()
736 if (spawn->fd_stdout >= 0) { in spawn_wait()
737 … r = sd_event_add_io(e, &stdout_source, spawn->fd_stdout, EPOLLIN, on_spawn_io, spawn); in spawn_wait()
739 … return log_device_debug_errno(spawn->device, r, "Failed to create stdio event source: %m"); in spawn_wait()
742 … return log_device_debug_errno(spawn->device, r, "Failed to enable stdio event source: %m"); in spawn_wait()
745 if (spawn->fd_stderr >= 0) { in spawn_wait()
746 … r = sd_event_add_io(e, &stderr_source, spawn->fd_stderr, EPOLLIN, on_spawn_io, spawn); in spawn_wait()
748 … return log_device_debug_errno(spawn->device, r, "Failed to create stderr event source: %m"); in spawn_wait()
751 … return log_device_debug_errno(spawn->device, r, "Failed to enable stderr event source: %m"); in spawn_wait()
754 r = sd_event_add_child(e, &sigchld_source, spawn->pid, WEXITED, on_spawn_sigchld, spawn); in spawn_wait()
756 … return log_device_debug_errno(spawn->device, r, "Failed to create sigchild event source: %m"); in spawn_wait()
760 …return log_device_debug_errno(spawn->device, r, "Failed to set priority to sigchild event source: … in spawn_wait()
778 Spawn spawn; in udev_event_spawn() local
843 spawn = (Spawn) { in udev_event_spawn()
857 r = spawn_wait(&spawn); in udev_event_spawn()
863 result[spawn.result_len] = '\0'; in udev_event_spawn()
866 *ret_truncated = spawn.truncated; in udev_event_spawn()