From 0f2635159e1086a8b03d32644cf3c8f135d90a32 Mon Sep 17 00:00:00 2001 From: duff Date: Sat, 13 Sep 2008 10:16:22 +0000 Subject: [PATCH] =?UTF-8?q?=E2=80=A2=20do=20not=20watch=20for=20error=20co?= =?UTF-8?q?nditions=20on=20the=20pipes,=20since=20no=20errors=20are=20defi?= =?UTF-8?q?ned,=20yet=20one=20may=20arise=20presumably=20due=20to=20a=20bu?= =?UTF-8?q?g=20=E2=80=A2=20use=20the=20TMPDIR=20environment=20variable=20t?= =?UTF-8?q?o=20get=20the=20location=20of=20the=20temporary=20directory=20(?= =?UTF-8?q?used=20for=20the=20named=20pipes)=20rather=20than=20hardcoded?= =?UTF-8?q?=20=E2=80=98/tmp=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://svn.textmate.org/branches/WIP/Tools/Dialog2@10554 dfb7d73b-c2ec-0310-8fea-fb051d288c6d --- tm_dialog2.mm | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/tm_dialog2.mm b/tm_dialog2.mm index 205c07b..1cbd42b 100644 --- a/tm_dialog2.mm +++ b/tm_dialog2.mm @@ -39,7 +39,7 @@ id connect () char const* create_pipe (char const* name) { char* filename; - asprintf(&filename, "/tmp/dialog_fifo_%d_%s", getpid(), name); + asprintf(&filename, "%s/dialog_fifo_%d_%s", getenv("TMPDIR") ?: "/tmp", getpid(), name); int res = mkfifo(filename, 0666); if((res == -1) && (errno != EEXIST)) { @@ -106,18 +106,17 @@ int main (int argc, char const* argv[]) while(fd_map.size() > 1 || (fd_map.size() == 1 && fd_map.find(STDIN_FILENO) == fd_map.end())) { - fd_set readfds, writefds, errorfds; - FD_ZERO(&readfds); FD_ZERO(&writefds); FD_ZERO(&errorfds); + fd_set readfds, writefds; + FD_ZERO(&readfds); FD_ZERO(&writefds); int num_fds = 0; iterate(it, fd_map) { FD_SET(it->first, &readfds); - FD_SET(it->first, &errorfds); num_fds = std::max(num_fds, it->first + 1); } - int i = select(num_fds, &readfds, &writefds, &errorfds, NULL); + int i = select(num_fds, &readfds, &writefds, NULL, NULL); if(i == -1) { perror("Error from select"); @@ -136,13 +135,6 @@ int main (int argc, char const* argv[]) to_remove.push_back(it); // we can’t remove as long as we need the iterator for the ++ else write(it->second, buf, len); } - - if(FD_ISSET(it->first, &errorfds)) - { - // only report a problem when owner is not -1 since there is a bug () where errors are reported for file descriptors with -1 as owner (which is the case when using here-docs/here-strings for stdin) - if(fcntl(STDIN_FILENO, F_GETOWN) != -1) - fprintf(stderr, "error condition on %d\n", it->first); - } } iterate(it, to_remove)