Repository: zellij-org/zellij
File: src/common/os_input_output.rs (Rust)

Code before:
        // the terminal we're trying to kill hangs on SIGINT and so all the app gets stuck
        // that's why we're sending SIGKILL here
        // A better solution would be to send SIGINT here and not wait for it, and then have
        // a background thread do the waitpid stuff and send SIGKILL if the process is stuck
        kill(Pid::from_raw(pid), Some(Signal::SIGKILL)).unwrap();
        waitpid(Pid::from_raw(pid), None).unwrap();
        Ok(())
    }
    fn receive_sigwinch(&self, cb: Box<dyn Fn()>) {
        let mut signals = Signals::new(&[SIGWINCH, SIGTERM, SIGINT, SIGQUIT]).unwrap();
        for signal in signals.forever() {
            match signal {
                SIGWINCH => {
                    cb();
                }
                SIGTERM | SIGINT | SIGQUIT => {
                    break;
                }
                _ => unreachable!(),
            }
        }
    }
    fn load_palette(&self) -> Palette {
        let palette = match Colors::new("xresources") {
            Some(palette) => {
                let fg = if let Some(foreground) = hex_to_rgb(&palette.fg) {
                    foreground
                } else {
                    return default_palette();
                };

                let bg = if let Some(background) = hex_to_rgb(&palette.bg) {
                    background
                } else {
                    return default_palette();
                };

                let colors: Vec<(u8, u8, u8)> = palette
                    .colors
                    .iter()
                    .map(|c| hex_to_rgb(c).unwrap())
                    .collect();
                let theme = detect_theme(bg);
                Palette {
                    source: PaletteSource::Xresources,
                    theme,
                    fg,
                    bg,
                    black: colors[0],
                    red: colors[1],
                    green: colors[2],

Review comment (suggestion):
If `hex_to_rgb` should be like [this](https://github.com/zellij-org/zellij/pull/437/files#r624784691) comment, this line might be fixed with the following change (`palette.bg` is also fixed as the same change :smile:)

```suggestion
                let fg = if let Some(foreground) = palette.fg.as_deref().map(hex_to_rgb) {
```

Code after:
        // the terminal we're trying to kill hangs on SIGINT and so all the app gets stuck
        // that's why we're sending SIGKILL here
        // A better solution would be to send SIGINT here and not wait for it, and then have
        // a background thread do the waitpid stuff and send SIGKILL if the process is stuck
        kill(Pid::from_raw(pid), Some(Signal::SIGKILL)).unwrap();
        waitpid(Pid::from_raw(pid), None).unwrap();
        Ok(())
    }
    fn receive_sigwinch(&self, cb: Box<dyn Fn()>) {
        let mut signals = Signals::new(&[SIGWINCH, SIGTERM, SIGINT, SIGQUIT]).unwrap();
        for signal in signals.forever() {
            match signal {
                SIGWINCH => {
                    cb();
                }
                SIGTERM | SIGINT | SIGQUIT => {
                    break;
                }
                _ => unreachable!(),
            }
        }
    }
    fn load_palette(&self) -> Palette {
        let palette = match Colors::new("xresources") {
            Some(palette) => {
                let fg = if let Some(foreground) = palette.fg.as_deref().map(hex_to_rgb) {
                    foreground
                } else {
                    return default_palette();
                };

                let bg = if let Some(background) = palette.bg.as_deref().map(hex_to_rgb) {
                    background
                } else {
                    return default_palette();
                };

                // NOTE: `16` is the same as the length of `palette.colors`.
                let mut colors: [(u8, u8, u8); 16] = [(0, 0, 0); 16];
                for (idx, color) in palette.colors.iter().enumerate() {
                    if let Some(c) = color {
                        colors[idx] = hex_to_rgb(c);
                    } else {
                        return default_palette();
                    }
                }
                let theme = detect_theme(bg);
                Palette {
                    source: PaletteSource::Xresources,
                    theme,
                    fg,