Skip to content

Commit bc4a372

Browse files
committed
wip
1 parent 1301d6a commit bc4a372

File tree

4 files changed

+45
-5
lines changed

4 files changed

+45
-5
lines changed

.cargo/config.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
[build]
22
rustflags = ["--cfg", "tokio_unstable"]
3+
4+
[registries.crates-io]
5+
protocol = "sparse"

Cargo.lock

Lines changed: 32 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

common/src/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ pub async fn ctrl_c() {
8484
#[cfg(unix)]
8585
pub async fn usr1() {
8686
use tokio::signal::unix::{signal, SignalKind};
87-
let mut usr1 = signal(SignalKind::user()).unwrap();
87+
let mut usr1 = signal(SignalKind::user_defined1()).unwrap();
8888
let _ = usr1.recv().await
8989
}
9090

receiver/src/bot.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,16 @@ async fn stop(ctx: Context<'_>) -> Result<()> {
218218
{
219219
let mut pid = ctx.data().currently_playing_pid.read().unwrap();
220220
if let Some(pid) = pid.as_ref().take() {
221+
let pid = Pid::from_raw(pid as i32);
221222
tracing::debug!(?pid, "asking player to stop");
222-
let _ = nix::sys::signal::kill(Pid::from_raw(pid as i32), Signal::SIGUSR1);
223-
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
223+
let _ = nix::sys::signal::kill(pid, Signal::SIGUSR1);
224+
225+
// wait for it to exit, or timeout
226+
tokio::select! {
227+
_ = tokio::time::sleep(std::time::Duration::from_secs(1)) => {},
228+
_ = nix::sys::wait::waitpid(pid, None) => {},
229+
}
230+
224231
}
225232
}
226233

0 commit comments

Comments
 (0)