Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libstd/os.rs shows Pipe{ input, out } and order of members needs to be switched to match the posix API #9458

Closed
glycerine opened this issue Sep 24, 2013 · 2 comments

Comments

@glycerine
Copy link

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.

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.
@glycerine
Copy link
Author

maybe just relabel them "readme" and "writeme" :)

@huonw
Copy link
Member

huonw commented Jan 26, 2014

Triage: I'll modernise Pipe in the next day or so, and fix this while I'm at it.

djkoloski pushed a commit to djkoloski/rust that referenced this issue Sep 21, 2022
Use `visit_expr_field` for `ParamPosition`

A small change to make it a little simpler

changelog: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants