Plan 9 from Bell Labs’s /usr/web/sources/contrib/rsc/linuxemu/libc/linux/9/pipe.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#include <u.h>
#include <libc.h>
#include "../syscall/syscall.h"

/*
 * SOCK_SEQSTREAM preserves message boundaries (Plan 9 pipe)
 * but if you read the first 5 bytes of a 10 byte message,
 * throws the rest of the message away.
 *
 * SOCK_STREAM does not preserve message boundaries (Unix pipe).
 *
 * Let's try SOCK_SEQPACKET for now.
 */
int
pipe(int *fd)
{
	ulong arg[4];

	arg[0] = PF_UNIX;
	arg[1] = SOCK_SEQPACKET;
	arg[2] = 0;
	arg[3] = (ulong)fd;

	return linuxsocketcall(SOCKOP_SOCKETPAIR, arg);
}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.