[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Nano-devel] Patch to execute external command and inerst output int
From: |
Chris Allegretta |
Subject: |
Re: [Nano-devel] Patch to execute external command and inerst output into buffer... |
Date: |
Thu, 21 Mar 2002 18:59:11 -0500 |
User-agent: |
Mutt/1.3.25i |
On Thu, Mar 21, 2002 at 12:55:50AM -0600, Dwayne Rightler wrote:
>
> Now I am having trouble reproducing the segfault... it happened for me
> twice and now it doesnt... heh.... Anyway here is a patch which fixes the
> ugly stderr output...
Hi Dwayne,
I just hacked this together and committed it to CVS, but what do
you think:
#ifndef NANO_SMALL
int open_pipe(char *command)
{
int fd[2], pid;
/* Make our pipes. */
if (pipe(fd) == -1) {
statusbar("Could not pipe");
return 1;
}
/* Fork a child */
if ((pid = fork()) == 0) {
close(fd[0]);
dup2(fd[1], fileno(stdout));
dup2(fd[1], fileno(stderr));
/* If execl() returns at all, there was an error. */
execl("/bin/sh","/bin/sh","-c",command,0);
exit(0);
}
else if (pid == -1) {
statusbar(_("Could not fork"));
return 1;
}
/* Else continue as parent */
close(fd[1]);
read_file(fd[0],"stdin",0);
set_modified();
return 0;
}
#endif /* NANO_SMALL */
Chris A
--
Chris Allegretta http://www.asty.org
"Share and Enjoy" - Douglas Adams, 1952 - 2001
- [Nano-devel] Patch to execute external command and inerst output into buffer..., Dwayne Rightler, 2002/03/10
- Re: [Nano-devel] Patch to execute external command and inerst output into buffer..., Jordi Mallach, 2002/03/21
- [Nano-devel] Patch to do_justify, David Benbennick, 2002/03/21
- Re: [Nano-devel] Patch to do_justify, Chris Allegretta, 2002/03/21
- [Nano-devel] Patch to files.c:read_file, David Benbennick, 2002/03/26
- [Nano-devel] Patch to files.c, David Benbennick, 2002/03/26
- Re: [Nano-devel] Patch to files.c, Chris Allegretta, 2002/03/26
- Re: [Nano-devel] Patch to files.c, David Benbennick, 2002/03/27
- Re: [Nano-devel] Patch to files.c, Chris Allegretta, 2002/03/27
- Re: [Nano-devel] Patch to files.c, David Benbennick, 2002/03/27