From ac68ac6c445417654ca8e04ac0327c8d5391ec11 Mon Sep 17 00:00:00 2001 From: KO Myung-Hun Date: Thu, 20 Jun 2024 19:41:35 +0900 Subject: [PATCH] Implement workaround of socketpair() new file: io/socketpair.c --- io/socketpair.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 io/socketpair.c diff --git a/io/socketpair.c b/io/socketpair.c new file mode 100644 index 0000000..f19041d --- /dev/null +++ b/io/socketpair.c @@ -0,0 +1,27 @@ +/* + * socketpair() workaround for OS/2 kLIBC + * + * Copyright (C) 2024 KO Myung-Hun + * + * This program is free software. It comes without any warranty, to + * the extent permitted by applicable law. You can redistribute it + * and/or modify it under the terms of the Do What The Fuck You Want + * To Public License, Version 2, as published by Sam Hocevar. See + * http://www.wtfpl.net/ for more details. + */ + +/* + * Dependencies: None + */ + +#include + +/* OS/2 kLIBC quits a program without flushing a stream associated with a + * socket. This leads to loss of buffered data of a stream. So flush before + * a program ends. + */ +__attribute__((destructor)) +static void flush( void ) +{ + flushall(); +}