Skip to content

Commit

Permalink
Implement workaround of socketpair()
Browse files Browse the repository at this point in the history
    new file:   io/socketpair.c
  • Loading branch information
komh committed Jun 20, 2024
1 parent afffa2a commit ac68ac6
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions io/socketpair.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* socketpair() workaround for OS/2 kLIBC
*
* Copyright (C) 2024 KO Myung-Hun <[email protected]>
*
* 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 <stdio.h>

/* 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();
}

0 comments on commit ac68ac6

Please sign in to comment.