Skip to content

Tag: c++

boost asio notify server of disconnect

I was wondering if there is any way to notify a server if a client side application was closed. Normally, if I Ctrl+C my client side terminal an EOF-signal is sent to the server side. The server side async_read function has a handle which has boost::system::error_code ec argument fed into it. The handle is ca…

Running bash using posix instead of fork/execv

I have a CLI, one of the commands is entering into Linux bash shell. This is the code which does it using fork & execv: I want to replace the fork/execv and to use posix_spawn instead: But it doesn’t work. Any help? Answer Let’s look at what the code in the original fork/exec does: close all f…

Linux: Reading file while other program might modify it

A program Foo periodically updates a file and calls my C program Bar to process the file. The issue is that the Foo might update the file, call Bar to process it, and while Bar reads the file, Foo might update the file again. Is it possible for Bar to read the file in inconsistent state, e.g. read first half