dylni / process_control Goto Github PK
View Code? Open in Web Editor NEWErgonomically run processes with limits.
Home Page: https://crates.io/crates/process_control
License: Other
Ergonomically run processes with limits.
Home Page: https://crates.io/crates/process_control
License: Other
A commit was merged to increase the version of windows-sys 0.42, but no new version has been released yet. This would be nice to have ๐
It would be cool to also limit a proccesses CPU usage similar to https://github.com/aoldershaw/proclimit
Hi, @dylni ๐
unfortunately, those boring Starship folks are back again to report some more issues ๐
This time v3.0.1
failed to compile inside termux/package-builder
docker image (https://github.com/termux/termux-packages/blob/master/scripts/Dockerfile) which is used for cross-compiling Termux packages:
https://github.com/termux/termux-packages/runs/1944936544
I believe the environment itself isn't problematic but the way how si_status
gets retrieved. Maybe I'm reading this completely wrong and at risk of asking something totally stupid: is it accidentally invoked instead of just being accessed? ๐ค
https://github.com/dylni/process_control/blob/3.0.1/src/unix.rs#L171
signal.h
manpage says si_status
should be declared as an int
struct member:
The <signal.h> header shall define the
siginfo_t
type as a
structure, which shall include at least the following members:int si_signo Signal number. int si_code Signal code. int si_errno If non-zero, an errno value associated with this signal, as described in <errno.h>. pid_t si_pid Sending process ID. uid_t si_uid Real user ID of sending process. void *si_addr Address of faulting instruction. int si_status Exit value or signal. long si_band Band event for SIGPOLL. union sigval si_value Signal value.
and compilation ends with following error:
error[E0599]: no method named `si_status` found for struct `siginfo_t` in the current scope
--> /home/builder/.cargo/registry/src/github.com-1ecc6299db9ec823/process_control-3.0.1/src/unix.rs:171:58
|
171 | ... value: unsafe { process_info.si_status() },
| ^^^^^^^^^ method not found in `siginfo_t`
Once again, thank you for all your patience and extensive help in dealing with BSDs, and thank you in advance for all the future help! ๐ฏ
Name | About | Title | Label |
---|---|---|---|
Propose a change that introduces a new functionality that allows detecting when the memory limit of a process has been exceeded and if it exceeds it, killing the process. | Memory Limit Exceeded Support | request |
It is very useful when you are going to execute processes in which the established memory limit can be exceeded, for example when you execute a process that runs a programming code of some user, such as a Virtual Programming Judge.
let process = Command::new("echo")
.arg("hello")
.stdout(Stdio::piped())
.spawn()?;
process
.with_output_timeout(Duration::from_secs(1))
.memory_limit_exceeded(512MB)
.terminating()
.wait()?
.kill_by_memory_limit_exceeded(|| {
// Process Memory Limit Exceeded
})
.kill_by_timeout(|| {
// Process timed out
})?;
Hello, I got a compile failure trying to build this on OpenBSD -CURRENT, with rust 1.48 and process_control 3.0.1:
error[E0432]: unresolved import `libc::P_PID`
--> /home/x/.cargo/registry/src/github.com-1ecc6299db9ec823/process_control-3.0.1/src/unix.rs:18:5
|
18 | use libc::P_PID;
| ^^^^^^^^^^^ no `P_PID` in the root
error[E0432]: unresolved import `libc::WEXITED`
--> /home/x/.cargo/registry/src/github.com-1ecc6299db9ec823/process_control-3.0.1/src/unix.rs:20:5
|
20 | use libc::WEXITED;
| ^^^^^^-------
| | |
| | help: a similar name exists in the module: `WIFEXITED`
| no `WEXITED` in the root
error[E0432]: unresolved import `libc::WNOWAIT`
--> /home/x/.cargo/registry/src/github.com-1ecc6299db9ec823/process_control-3.0.1/src/unix.rs:21:5
|
21 | use libc::WNOWAIT;
| ^^^^^^^^^^^^^ no `WNOWAIT` in the root
error[E0432]: unresolved import `libc::WSTOPPED`
--> /home/x/.cargo/registry/src/github.com-1ecc6299db9ec823/process_control-3.0.1/src/unix.rs:22:5
|
22 | use libc::WSTOPPED;
| ^^^^^^--------
| | |
| | help: a similar name exists in the module: `WIFSTOPPED`
| no `WSTOPPED` in the root
Compiling crossbeam-deque v0.8.0
error[E0425]: cannot find function `waitid` in crate `libc`
--> /home/x/.cargo/registry/src/github.com-1ecc6299db9ec823/process_control-3.0.1/src/unix.rs:159:27
|
159 | libc::waitid(
| ^^^^^^ help: a function with a similar name exists: `waitpid`
|
::: /home/x/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.84/src/unix/mod.rs:995:5
|
995 | / pub fn waitpid(
996 | | pid: pid_t,
997 | | status: *mut ::c_int,
998 | | options: ::c_int,
999 | | ) -> pid_t;
| |_______________- similarly named function `waitpid` defined here
error: aborting due to 5 previous errors
How would I fix this? Thanks!
I'm in the process of packaging Starship for NetBSD and recently ran into an issue similar to #4. It's been resolved in libc version 0.2.98 and process_control now works fine on NetBSD, at least for Starship's purposes.
Would it be possible to bump the libc dependency to version 0.2.98? This will make it a bit easier for us to build Starship on NetBSD as we'll no longer need to patch the build to do a local version override. Thanks!
Illumos is the open source fork of Solaris.
While trying to build Starship https://starship.rs/ I get ...
$ cargo build
Compiling process_control v3.2.1
error[E0432]: unresolved import `libc::CLD_EXITED`
--> /home/david/.cargo/registry/src/github.com-1ecc6299db9ec823/process_control-3.2.1/src/unix.rs:17:5
|
17 | use libc::CLD_EXITED;
| ^^^^^^^^^^^^^^^^ no `CLD_EXITED` in the root
error[E0277]: the trait bound `i32: From<u32>` is not satisfied
--> /home/david/.cargo/registry/src/github.com-1ecc6299db9ec823/process_control-3.2.1/src/unix.rs:239:29
|
239 | pid.into(),
| ^^^^ the trait `From<u32>` is not implemented for `i32`
|
= help: the following implementations were found:
<i32 as From<NonZeroI32>>
<i32 as From<bool>>
<i32 as From<i16>>
<i32 as From<i8>>
and 2 others
= note: required because of the requirements on the impl of `Into<i32>` for `u32`
error[E0599]: no method named `si_status` found for struct `siginfo_t` in the current scope
--> /home/david/.cargo/registry/src/github.com-1ecc6299db9ec823/process_control-3.2.1/src/unix.rs:249:58
|
249 | ... value: unsafe { process_info.si_status() },
| ^^^^^^^^^ method not found in `siginfo_t`
Some errors have detailed explanations: E0277, E0432, E0599.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `process_control` due to 3 previous errors
which looks at least a bit like it might be related to #4
I realise that this is a Weird Platform, so if you need it I expect I can set up a guest account if that would help with debugging.
openbsd% git clone https://github.com/dylni/process_control
Cloning into 'process_control'...
remote: Enumerating objects: 590, done.
remote: Counting objects: 100% (306/306), done.
remote: Compressing objects: 100% (183/183), done.
remote: Total 590 (delta 171), reused 225 (delta 104), pack-reused 284
Receiving objects: 100% (590/590), 134.88 KiB | 160.00 KiB/s, done.
Resolving deltas: 100% (338/338), done.
openbsd% cd process_control
openbsd% ls
COPYRIGHT LICENSE-APACHE README.md src
Cargo.toml LICENSE-MIT rustfmt.toml tests
openbsd% cargo test
Updating `sjtu` index
Compiling libc v0.2.122
Compiling process_control v3.4.0 (/home/flw/process_control)
error[E0432]: unresolved import `libc::P_PID`
--> src/unix/mod.rs:16:5
|
16 | use libc::P_PID;
| ^^^^^^^^^^^ no `P_PID` in the root
error[E0432]: unresolved import `libc::WEXITED`
--> src/unix/mod.rs:18:5
|
18 | use libc::WEXITED;
| ^^^^^^-------
| | |
| | help: a similar name exists in the module: `WIFEXITED`
| no `WEXITED` in the root
error[E0432]: unresolved import `libc::WNOWAIT`
--> src/unix/mod.rs:19:5
|
19 | use libc::WNOWAIT;
| ^^^^^^^^^^^^^ no `WNOWAIT` in the root
error[E0432]: unresolved import `libc::WSTOPPED`
--> src/unix/mod.rs:20:5
|
20 | use libc::WSTOPPED;
| ^^^^^^--------
| | |
| | help: a similar name exists in the module: `WIFSTOPPED`
| no `WSTOPPED` in the root
error[E0425]: cannot find function `waitid` in crate `libc`
--> src/unix/mod.rs:197:27
|
197 | libc::waitid(
| ^^^^^^ help: a function with a similar name exists: `waitpid`
|
::: /home/flw/.cargo/registry/src/mirrors.sjtug.sjtu.edu.cn-7a04d2510079875b/libc-0.2.122/src/unix/mod
.rs:932:5
|
932 | pub fn waitpid(pid: pid_t, status: *mut ::c_int, options: ::c_int) -> pid_t;
| ---------------------------------------------------------------------------- similarly named fu
nction `waitpid` defined here
error[E0599]: no method named `si_status` found for struct `siginfo_t` in the current scope
--> src/unix/exit_status.rs:59:42
|
59 | value: unsafe { process_info.si_status() },
| ^^^^^^^^^ method not found in `siginfo_t`
Some errors have detailed explanations: E0425, E0432, E0599.
For more information about an error, try `rustc --explain E0425`.
error: could not compile `process_control` due to 6 previous errors
openbsd%
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.