Ticket #2949 (new enhancement) — at Initial Version
[ Optimization ]: replace pipe() by pipe2()
Reported by: | pavlinux | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | |
Component: | mc-core | Version: | master |
Keywords: | Cc: | gotar@… | |
Blocked By: | Blocking: | ||
Branch state: | no branch | Votes for changeset: |
Description
Linux only :-P
- The pipe2() was added to Linux in version 2.6.27. It is a variant of the normal
- pipe syscall, but takes an extra flags argument which can be the ORed value of
- O_NONBLOCK and O_CLOEXEC. The original pipe syscall is now defined as like the
- pipe2 syscall, but with the flags variable set to zero.
- The pipe2() glibc support is available starting with version 2.9.
- The pipe2() is Linux-specific.
-
lib/utilunix.c
diff --git a/lib/utilunix.c b/lib/utilunix.c index c3c6704..0127544 100644
a b tilde_expand (const char *directory) 340 340 void 341 341 open_error_pipe (void) 342 342 { 343 if (pipe (error_pipe) < 0)343 if (pipe2(error_pipe, O_DIRECT) < 0) 344 344 { 345 345 message (D_NORMAL, _("Warning"), _("Pipe failed")); 346 346 } -
src/background.c
diff --git a/src/background.c b/src/background.c index a68fe86..affe8c0 100644
a b do_background (struct FileOpContext *ctx, char *info) 514 514 int back_comm[2]; /* back connection */ 515 515 pid_t pid; 516 516 517 if (pipe (comm) == -1)517 if (pipe2(comm, O_DIRECT) == -1) 518 518 return -1; 519 519 520 if (pipe (back_comm) == -1)520 if (pipe2(back_comm, O_DIRECT) == -1) 521 521 return -1; 522 522 523 523 pid = fork (); -
src/cons.handler.c
diff --git a/src/cons.handler.c b/src/cons.handler.c index 610db28..97a09b6 100644
a b handle_console_linux (console_action_t action) 148 148 status = close (pipefd1[1]); 149 149 status = close (pipefd2[0]); 150 150 /* Create two pipes for communication */ 151 if (!((pipe (pipefd1) == 0) && ((pipe (pipefd2)) == 0)))151 if (!((pipe2(pipefd1, O_DIRECT) == 0) && ((pipe2(pipefd2, O_DIRECT)) == 0))) 152 152 { 153 153 mc_global.tty.console_flag = '\0'; 154 154 break; -
src/subshell.c
diff --git a/src/subshell.c b/src/subshell.c index 510cf4d..b19117a 100644
a b init_subshell (void) 850 850 return; 851 851 } 852 852 } 853 else /* subshell_type is BASH or ZSH */ if (pipe (subshell_pipe))853 else /* subshell_type is BASH or ZSH */ if (pipe2(subshell_pipe, O_DIRECT)) 854 854 { 855 855 perror (__FILE__ ": couldn't create pipe"); 856 856 mc_global.tty.use_subshell = FALSE; -
src/vfs/fish/fish.c
diff --git a/src/vfs/fish/fish.c b/src/vfs/fish/fish.c index 5c84175..e02ec77 100644
a b fish_pipeopen (struct vfs_s_super *super, const char *path, const char *argv[]) 312 312 int fileset1[2], fileset2[2]; 313 313 int res; 314 314 315 if ((pipe (fileset1) < 0) || (pipe (fileset2) < 0))315 if ((pipe2(fileset1, O_DIRECT) < 0) || (pipe2(fileset2, O_DIRECT) < 0)) 316 316 vfs_die ("Cannot pipe(): %m."); 317 317 318 318 res = fork ();
Note: See
TracTickets for help on using
tickets.