• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javaandroidc++linuxc#objective-ccocoa誰得qtrubypythonwindowsphpgamebathyscapheguic翻訳omegattwitterframeworkbtronvb.net計画中(planning stage)testdomarduinodirectxpreviewerゲームエンジン

TextMate is a graphical text editor for OS X 10.7+


Commit MetaInfo

Revision0808712630c891592e8b5789f51b4cc992731342 (tree)
Time2012-08-24 03:25:17
AuthorAllan Odgaard <git@abet...>
CommiterAllan Odgaard

Log Message

Use |O_CLOEXEC when possible

This avoids having to do a fcntl(fd, F_SETFD, FD_CLOEXEC) to set the “close on exec” flag.

Change Summary

Incremental Difference

--- a/Frameworks/document/src/watch.cc
+++ b/Frameworks/document/src/watch.cc
@@ -209,13 +209,10 @@ namespace document
209209 void watch_server_t::observe (watch_info_t& info, size_t client_id)
210210 {
211211 info.path_watched = existing_parent(info.path);
212- info.fd = open(info.path_watched.c_str(), O_EVTONLY, 0);
213- if(info.fd == -1)
212+ info.fd = open(info.path_watched.c_str(), O_EVTONLY|O_CLOEXEC, 0);
213+ if(info.fd == -1) // TODO we need to actually handle this error @allan
214214 fprintf(stderr, "error observing path, open(\"%s\"): %s\n", info.path_watched.c_str(), strerror(errno));
215215
216- // TODO we need to actually handle this error @allan
217- fcntl(info.fd, F_SETFD, 1);
218-
219216 struct kevent changeList;
220217 struct timespec timeout = { };
221218 EV_SET(&changeList, info.fd, EVFILT_VNODE, EV_ADD | EV_ENABLE | EV_CLEAR, NOTE_DELETE | NOTE_WRITE | NOTE_RENAME | NOTE_ATTRIB, 0, (void*)client_id);
--- a/Frameworks/settings/src/track_paths.h
+++ b/Frameworks/settings/src/track_paths.h
@@ -161,7 +161,7 @@ struct track_paths_t
161161 private:
162162 static int open_file (std::string const& path, bool* exists)
163163 {
164- int fd = open(path.c_str(), O_EVTONLY/*|O_CLOEXEC*/, 0);
164+ int fd = open(path.c_str(), O_EVTONLY|O_CLOEXEC, 0);
165165 return fd == -1 && errno == ENOENT ? (*exists = false), open_file(path::parent(path), exists) : fd;
166166 }
167167