mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-28 22:03:12 +00:00
topic_monitor to migrate from wperror to perror
This avoids needing to use the ffi
This commit is contained in:
parent
15361f62ed
commit
35f8f421fe
1 changed files with 8 additions and 11 deletions
|
@ -24,8 +24,8 @@ use crate::fd_readable_set::fd_readable_set_t;
|
||||||
use crate::fds::{self, AutoClosePipes};
|
use crate::fds::{self, AutoClosePipes};
|
||||||
use crate::ffi::{self as ffi, c_int};
|
use crate::ffi::{self as ffi, c_int};
|
||||||
use crate::flog::{FloggableDebug, FLOG};
|
use crate::flog::{FloggableDebug, FLOG};
|
||||||
use crate::wchar::{widestrs, wstr, WString};
|
use crate::wchar::WString;
|
||||||
use crate::wchar_ffi::wcharz;
|
use crate::wutil::perror;
|
||||||
use nix::errno::Errno;
|
use nix::errno::Errno;
|
||||||
use nix::unistd;
|
use nix::unistd;
|
||||||
use std::cell::UnsafeCell;
|
use std::cell::UnsafeCell;
|
||||||
|
@ -88,7 +88,6 @@ pub fn all_topics() -> [topic_t; 3] {
|
||||||
[topic_t::sighupint, topic_t::sigchld, topic_t::internal_exit]
|
[topic_t::sighupint, topic_t::sigchld, topic_t::internal_exit]
|
||||||
}
|
}
|
||||||
|
|
||||||
#[widestrs]
|
|
||||||
impl generation_list_t {
|
impl generation_list_t {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self::default()
|
Self::default()
|
||||||
|
@ -225,14 +224,13 @@ impl binary_semaphore_t {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Release a waiting thread.
|
/// Release a waiting thread.
|
||||||
#[widestrs]
|
|
||||||
pub fn post(&self) {
|
pub fn post(&self) {
|
||||||
// Beware, we are in a signal handler.
|
// Beware, we are in a signal handler.
|
||||||
if self.sem_ok_ {
|
if self.sem_ok_ {
|
||||||
let res = unsafe { libc::sem_post(self.sem_.get()) };
|
let res = unsafe { libc::sem_post(self.sem_.get()) };
|
||||||
// sem_post is non-interruptible.
|
// sem_post is non-interruptible.
|
||||||
if res < 0 {
|
if res < 0 {
|
||||||
self.die("sem_post"L);
|
self.die("sem_post");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Write exactly one byte.
|
// Write exactly one byte.
|
||||||
|
@ -247,14 +245,13 @@ impl binary_semaphore_t {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if !success {
|
if !success {
|
||||||
self.die("write"L);
|
self.die("write");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Wait for a post.
|
/// Wait for a post.
|
||||||
/// This loops on EINTR.
|
/// This loops on EINTR.
|
||||||
#[widestrs]
|
|
||||||
pub fn wait(&self) {
|
pub fn wait(&self) {
|
||||||
if self.sem_ok_ {
|
if self.sem_ok_ {
|
||||||
let mut res;
|
let mut res;
|
||||||
|
@ -267,7 +264,7 @@ impl binary_semaphore_t {
|
||||||
}
|
}
|
||||||
// Other errors here are very unexpected.
|
// Other errors here are very unexpected.
|
||||||
if res < 0 {
|
if res < 0 {
|
||||||
self.die("sem_wait"L);
|
self.die("sem_wait");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let fd = self.pipes_.read.fd();
|
let fd = self.pipes_.read.fd();
|
||||||
|
@ -288,14 +285,14 @@ impl binary_semaphore_t {
|
||||||
if amt.is_err()
|
if amt.is_err()
|
||||||
&& (amt.err() != Some(Errno::EINTR) && amt.err() != Some(Errno::EAGAIN))
|
&& (amt.err() != Some(Errno::EINTR) && amt.err() != Some(Errno::EAGAIN))
|
||||||
{
|
{
|
||||||
self.die("read"L);
|
self.die("read");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn die(&self, msg: &wstr) {
|
pub fn die(&self, msg: &str) {
|
||||||
ffi::wperror(wcharz!(msg));
|
perror(msg);
|
||||||
panic!("die");
|
panic!("die");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue