You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note that libstd/os.rs has Pipe{ input and out } member order backwards, so to use them, we have to use them backwards, writing to the out fd, and reading from the input fd. Doesn't it seem more natural to write to the input, and read from the out?
The correct order dictated by the underlying C API is be {out, input}.
I had the darndest time figuring out why my pipe code wouldn't work, then finally noticed this reversal of the labels in the implementation.
pipe(2) - Linux man page
Name
pipe, pipe2 - create pipe
Synopsis
#include <unistd.h>
int pipe(int pipefd[2]);
#define _GNU_SOURCE /* See feature_test_macros(7) */#include
<fcntl.h> /* Obtain O_* constant definitions */#include <unistd.h>
int pipe2(int pipefd[2], int flags);
Description
pipe() creates a pipe, a unidirectional data channel that can be used for interprocess communication. The array pipefd is used to return two file descriptors referring to the ends of the pipe. pipefd[0] refers to the read end of the pipe. pipefd[1] refers to the write end of the pipe.
The text was updated successfully, but these errors were encountered:
rustc 0.8-pre (570431f 2013-09-19 15:56:04 -0700)
Note that libstd/os.rs has Pipe{ input and out } member order backwards, so to use them, we have to use them backwards, writing to the out fd, and reading from the input fd. Doesn't it seem more natural to write to the input, and read from the out?
The correct order dictated by the underlying C API is be {out, input}.
I had the darndest time figuring out why my pipe code wouldn't work, then finally noticed this reversal of the labels in the implementation.
The text was updated successfully, but these errors were encountered: