Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ A Run is not idempotent: re-running builds on whatever is already on the branch,

## Failed runs

A **Failed run** is one that ends, including by Ctrl-C, without an open pull request from its Issue branch that targets the Base branch, is mergeable and has passing CI. Causes include the session exiting non-zero, no pull request or one with the wrong base, and running out of Repairs.
A **Failed run** is one that ends, including by Ctrl-C or a closed terminal, without an open pull request from its Issue branch that targets the Base branch, is mergeable and has passing CI. Causes include the session exiting non-zero, no pull request or one with the wrong base, and running out of Repairs.

A Failed run:

Expand Down
10 changes: 5 additions & 5 deletions src/interrupt.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
//! SIGINT and SIGTERM: recorded rather than fatal, so an interrupted Run can
//! still go through the Failed run path and clean up.
//! SIGINT, SIGTERM and SIGHUP: recorded rather than fatal, so an interrupted
//! Run can still go through the Failed run path and clean up.

use std::sync::Arc;
use std::sync::OnceLock;
use std::sync::atomic::{AtomicBool, Ordering};

use anyhow::{Context, Result};
use signal_hook::consts::{SIGINT, SIGTERM};
use signal_hook::consts::{SIGHUP, SIGINT, SIGTERM};

static REQUESTED: OnceLock<Arc<AtomicBool>> = OnceLock::new();

/// Start recording SIGINT and SIGTERM instead of dying on them.
/// Start recording SIGINT, SIGTERM and SIGHUP instead of dying on them.
pub fn install() -> Result<()> {
let flag = REQUESTED.get_or_init(|| Arc::new(AtomicBool::new(false)));
for signal in [SIGINT, SIGTERM] {
for signal in [SIGINT, SIGTERM, SIGHUP] {
signal_hook::flag::register(signal, Arc::clone(flag))
.context("could not install the signal handler")?;
}
Expand Down
5 changes: 5 additions & 0 deletions tests/failed_run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@ fn sigterm_while_the_session_runs_stops_it_and_fails_the_run() {
assert_interrupt_fails_the_run("TERM");
}

#[test]
fn sighup_while_the_session_runs_stops_it_and_fails_the_run() {
assert_interrupt_fails_the_run("HUP");
}

fn assert_interrupt_fails_the_run(signal: &str) {
let scenario = Scenario::new();
let started = scenario.path("agent-started");
Expand Down
Loading