Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(940)

Issue 100127: POSIX: Add code for shuffling file descriptors. (Closed)

Created:
11 years, 8 months ago by agl
Modified:
9 years, 7 months ago
CC:
chromium-reviews_googlegroups.com, Mark Mentovai, TVL
Visibility:
Public.

Description

POSIX: Add code for shuffling file descriptors. When forking a child process, one often wants to move existing file descriptors to well known locations (stdout, stderr etc). However, this is a process bedeviled with corner cases. Consider the case where you open two file descriptors, get assigned fds 1 and 0 for them and wish to shuffle them so that they end up in slots 0 and 1. Our current code fails in this case. We also have a problem where we're currently trying to mark file descriptors as close-on-exec rather than closing them in the child process. This is inherently broken in a multithreaded process where another thread can open a file descriptor and race the loop which is trying to mark them. Thus, on Linux we switch to close-after-fork where we known that no other threads exist in the process. On Mac, the code is sufficiently different that this simple fix isn't applicable and one of the Mac folks will need to take a look.

Patch Set 1 #

Patch Set 2 : ... #

Patch Set 3 : ... #

Patch Set 4 : ... #

Patch Set 5 : ... #

Unified diffs Side-by-side diffs Delta from patch set Stats (+540 lines, -30 lines) Patch
M base/base.gyp View 4 chunks +5 lines, -0 lines 0 comments Download
A base/file_descriptor_shuffle.h View 1 1 chunk +76 lines, -0 lines 0 comments Download
A base/file_descriptor_shuffle.cc View 1 2 3 4 1 chunk +92 lines, -0 lines 0 comments Download
A base/file_descriptor_shuffle_unittest.cc View 1 2 3 1 chunk +290 lines, -0 lines 0 comments Download
M base/process_util.h View 1 2 3 2 chunks +9 lines, -0 lines 0 comments Download
M base/process_util_linux.cc View 1 chunk +9 lines, -17 lines 0 comments Download
M base/process_util_posix.cc View 1 2 3 chunks +59 lines, -13 lines 0 comments Download

Messages

Total messages: 4 (0 generated)
agl
11 years, 8 months ago (2009-04-28 21:20:46 UTC) #1
Evan Martin
I think Markus, being the other Unixy person around here, might be a good reviewer ...
11 years, 8 months ago (2009-04-28 21:37:03 UTC) #2
jeremy
+mark, tvl agl: Thanks for fixing this, in future could you cc some Mac folk ...
11 years, 8 months ago (2009-04-28 22:22:42 UTC) #3
Markus (顧孟勤)
11 years, 7 months ago (2009-04-28 23:15:17 UTC) #4
LGTM

Powered by Google App Engine
This is Rietveld 408576698