Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Shim pipe and fcntl #2974

Merged
merged 2 commits into from
Aug 27, 2015
Merged

Shim pipe and fcntl #2974

merged 2 commits into from
Aug 27, 2015

Conversation

nguerrera
Copy link
Contributor

Add shims for pipe and fcntl.

Move the ignore of inheritability / O_CLOEXEC down to the shim.

Add a capability API for fcntl F_GET/SETPIPE_SZ. Originally, I was going to use errno = ENOTSUP alone, but the current behavior requires making a call in some cases before we even have a handle to invoke fcntl.

I went back and forth on how to shim fcntl, but decided on separate functions for each command (with just those that we use shimed for now. It's easier to reason about as the command effectively have different signatures and we lose strong typing if we mirror the '...' varargs of the native API. It also eliminates the complexity of converting the command code.

With this change, System.IO.Pipes can now have one build for all Unix targets.

internal static extern unsafe int FcntlGetPipeSz(int fd);

[DllImport(Libraries.SystemNative)]
internal static extern unsafe int FcntlSetPipeSz(int fd, int size);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should all of these methods instead be on the Fcntl type, e.g. Interop.Sys.Fcntl.GetPipeSz(fd)?

@stephentoub
Copy link
Member

Nice. I really like how this cleans things up, and I agree with the direction. A few comments, and otherwise LGTM.

@nguerrera nguerrera force-pushed the shim-pipe branch 2 times, most recently from c80e7f3 to d611b57 Compare August 26, 2015 18:54
return fcntl(fd, F_SETPIPE_SZ, size);
#else
errno = ENOTSUP;
return -1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, build failed due to lack of a semicolon ending this line.

@nguerrera nguerrera changed the title [WIP] Shim pipe and fcntl Shim pipe and fcntl Aug 26, 2015
@nguerrera
Copy link
Contributor Author

@stephentoub I think I've addressed everything and CI is green. Let me know if there's anything else.

@stephentoub
Copy link
Member

Looks great.

stephentoub added a commit that referenced this pull request Aug 27, 2015
@stephentoub stephentoub merged commit 86d077f into dotnet:master Aug 27, 2015
@nguerrera nguerrera deleted the shim-pipe branch September 4, 2015 18:40
@karelz karelz modified the milestone: 1.0.0-rtm Dec 3, 2016
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants