async_execute behavior with cancellation
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- cpp
- Ambito
- operating-systems
Direzione di ricerca
Inizia riproducendo le due varianti della issue con Boost 1.90, concentrandoti su process::async_wait, async_execute e sui valori di completamento di cancel_after. Leggi il commento di process::async_wait e la documentazione sui timeout, quindi determina il comportamento previsto per la cancellazione e i codici di uscita. Il lavoro è completato quando il comportamento è chiarito e la documentazione pertinente o i commenti dell’API lo descrivono accuratamente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Hi, I am trying to migrate from v1 to v2 (Boost 1.90).
I want to launch a child process, and terminate it, if it takes too long.
With v1, I used process::wait_for (currently only targeting windows, so that was fine).
The timeout example in the documentation for v2 hints at using something like async_execute(process(...)(asio::cancel_after(...))(some_handler).
That cancels the process fine, but I am having trouble to determine in the handler whether the process was terminated or exited okay.
Experimenting a bit, I found, that using proc.async_wait(boost::asio::cancel_after(...))(some_handler) behaves differently.
I am uncertain if that is a bug, or if I am missing something.
The behavior is as follows:
auto ctx = boost::asio::io_context{};
auto proc = boost::process::process(ctx, executable_path);
auto handle_exit_code = [](boost::system::error_code ec, int exitcode) {/*something*/};
// variant (a)
proc.async_wait(boost::asio::cancel_after(std::chrono::nanoseconds(1)))(handle_exit_code);
// variant (b)
boost::process::async_execute(std::move(proc))(boost::asio::cancel_after(std::chrono::nanoseconds(1)))(handle_exit_code);
ctx.run();
If the process times out in handle_exit_code, I get
- with variant (a):
ec == boost::asio::error::operation_abortedandexitcode==259, which corresponds toboost::process::v2::detail::still_active, I guess..? This behavior is useful to me. - with variant (b):
ecis not set (value==0) andexitcode==260. I have no idea what the260is, and it seems very unreliable to depend on it.
Sidenote: The comment at process::async_wait says
/// Asynchronously wait for the process to exit and deliver the native exit-code in the completion handler.
but the signature of the completion token is void(error_code, int), i.e. it uses int and not native_exit_code_type. So the comment is wrong and it is not the native exit-code, right?
There is no such comment at async_execute, so maybe it is supposed to behave differently? Either way, it would be nice if the behavior would be documented.
- Lingua principale
- C++
- Stelle
- 145
- Fork
- 151
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di boostorg/process
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 68/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
Tutte le issue di boostorg/process
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
ArthurSonzogni/FTXUI#1363 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
ginkgo-project/ginkgo#2108 ·
-
[CI] Nightly Clang build broken: structured binding captured in a lambda in FileDataSource.cpp Apertabug build
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 91/100
facebookincubator/velox#19194 ·
-
JIT-compiled number -> Decimal conversion silently overflows instead of raising DECIMAL_OVERFLOW Apertafuzz
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
ClickHouse/ClickHouse#122114 ·