Boost logo

Boost Users :

From: Marcus Alanen (maalanen_at_[hidden])
Date: 2005-09-26 14:45:23


Hello,

I have been toying with a framework for process management. I have opted
to catch SIGCHLD in my signal handler to handle child processes.
However, boost::iostreams does not seem to recognize system calls which
are interrupted, and throws exceptions.

Witness ./libs/iostreams/src/file_descriptor.cpp:

     errno = 0;
     std::streamsize result = BOOST_RTL(read)(pimpl_->fd_, s, n);
     if (errno != 0)
         throw detail::bad_read();
     return result == 0 ? -1 : result;

if ::read fails with errno == EINTR, a bad_read will result. This is
unfortunate, as caught SIGCHLD signals will result in spurious errors,
as the following strace shows:

...
read(9, 0x95d83ac, 4096) = ? ERESTARTSYS (To be restarted)
--- SIGCHLD (Child exited) @ 0 (0) ---
waitpid(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], WNOHANG) = 2407
sigreturn() = ? (mask now [])
write(2, "terminate called after throwing "..., 48) = 48
write(2, "std::ios_base::failure", 22) = 22
write(2, "\'\n", 2) = 2
write(2, " what(): ", 11) = 11
write(2, "bad read", 8) = 8
write(2, "\n", 1) = 1
...

As I understand it, boost was going to use ::read(), but the SIGCHLD got
in between, resulting in a an exception being thrown.

I realize that boost::process is not up and running yet, so this might
be a usage conflict of posix & boost. Can somebody please enlighten me
what the usage pattern here should be?

Thanks in advance,
Marcus


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net