iximiuz / shimmy

Simplistic container runtime shim
https://iximiuz.com/en/posts/implementing-container-runtime-shim/
39 stars 7 forks source link

Fix build issues #6

Closed fsmiamoto closed 1 year ago

fsmiamoto commented 2 years ago

As of 8226f532, build are failing locally with the report error below:

$ cargo build --bin shimmy
   Compiling shimmy v0.2.0 (/home/shigueo/code/shimmy)
error[E0599]: no variant or associated item named `from_c_int` found for enum `Signal` in the current scope
  --> src/nixtools/signal.rs:39:25
   |
39 |                 Signal::from_c_int(sinfo.ssi_signo as libc::c_int).expect("unexpected signo")
   |                         ^^^^^^^^^^ variant or associated item not found in `Signal`

For more information about this error, try `rustc --explain E0599`.
error: could not compile `shimmy` due to previous error

After fixing that, we get this:

$ cargo build --bin shimmy
   Compiling shimmy v0.2.0 (/home/shigueo/code/shimmy)
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
  --> src/main.rs:84:11
   |
84 |     match fork() {
   |           ^^^^^^ call to unsafe function
   |
   = note: consult the function's documentation for information on how to avoid undefined behavior

error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
   --> src/main.rs:104:29
    |
104 |     let runtime_pid = match fork() {
    |                             ^^^^^^ call to unsafe function
    |
    = note: consult the function's documentation for information on how to avoid undefined behavior

For more information about this error, try `rustc --explain E0133`.

This patch tries to fix those issues.

I'm a Rust n00b so probably there's a better way to do it but hey, at least I'm trying :sweat_smile:

iximiuz commented 2 years ago

Great catch! I'll gladly merge it, but could you please reformat it a bit? The unsafe {} blocks could be much smaller. Another minor ask - could you bump up the nix package version on the way? 🙏

fsmiamoto commented 1 year ago

Sorry for the delay and thank you so much for the review! I'll work on the changes and will submit them shortly

iximiuz commented 1 year ago

No problem at all! Thanks for your time and effort!

fsmiamoto commented 1 year ago

Hi @iximiuz, sorry once again for the delay haha I've been really busy up until now but hopefully the changes are good now.

iximiuz commented 1 year ago

Merged! Amazing work! Thanks a lot for giving some love to shimmy! 🤗