Rocco's mods to open_pipe

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1145 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
Chris Allegretta 2002-03-25 13:40:39 +00:00
parent f21f3fcc1e
commit bb88ece93c
2 changed files with 16 additions and 6 deletions

View File

@ -2,9 +2,10 @@ CVS code -
- General - General
- Type misalignments and mem leaks in renumber_all, do_justify - Type misalignments and mem leaks in renumber_all, do_justify
and do_spell (Rocco & Steven Kneizys). and do_spell (Rocco & Steven Kneizys).
- New "External Command" code, originally by Dwayne Rightler. - New "External Command" code, originally by Dwayne Rightler,
New function files.c:open_pipe(), changes to do_insertfile(), Chris & Rocco. New function files.c:open_pipe(), changes to
new list extcmd_list, cmd is ^X after ^R by default. do_insertfile(), new list extcmd_list, cmd is ^X after ^R by
default.
- Added separate regex variable (color_regex and colormatches) - Added separate regex variable (color_regex and colormatches)
so that color syntax and regex search/replace can coexist. so that color syntax and regex search/replace can coexist.
- files.c: - files.c:

15
files.c
View File

@ -26,6 +26,7 @@
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#include <errno.h> #include <errno.h>
@ -292,6 +293,7 @@ int read_file(int fd, char *filename, int quiet)
int open_pipe(char *command) int open_pipe(char *command)
{ {
int fd[2], pid; int fd[2], pid;
int fork_status;
/* Make our pipes. */ /* Make our pipes. */
@ -311,15 +313,22 @@ int open_pipe(char *command)
execl("/bin/sh","/bin/sh","-c",command,0); execl("/bin/sh","/bin/sh","-c",command,0);
exit(0); exit(0);
} }
else if (pid == -1) {
/* Else continue as parent */
close(fd[1]);
if (pid == -1) {
close(fd[0]);
statusbar(_("Could not fork")); statusbar(_("Could not fork"));
return 1; return 1;
} }
/* Else continue as parent */
close(fd[1]);
read_file(fd[0],"stdin",0); read_file(fd[0],"stdin",0);
set_modified(); set_modified();
wait(&fork_status);
return 0; return 0;
} }
#endif /* NANO_SMALL */ #endif /* NANO_SMALL */