Mail Archives: djgpp/1997/02/19/21:50:21
This is a multi-part message in MIME format.
--------------439434646885
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Eli Zaretskii wrote:
>
> > I _think_ the problem can be solved by making redir call system()
> > instead of spawnvp().
>
> This is indeed the solution. Would you please submit the patches?
> Thanks.
Okay, I've made the patch and am attaching it to this message. It tests
out okay with the original 'rm' bug, but I'm worried that the technique
I use would be vulnerable to crashes with extremely long command lines.
Should I use more than 4096 bytes for the buffer? It's hard to imagine
a command line to redir being longer than 51 screen lines, and I don't
want to use too much extra memory, but odder things have happened...
In any case, it's trivial to increase the size of the buffer.
If this patch checks out, I'll submit it as a fixed bug report to the
bug tracking system.
P.S.: I also fixed a typo in the usage() screen. ("warranty" is the
legal right, "warrantee" is the person who receives that right) ;)
To Vyacheslav and others: you can apply this patch by downloading
'v2/djlsr201.zip' and 'v2gnu/pat21b.zip'. Place the patch file in the
src/utils directory and type "patch <redir.dif" (or whatever you called
it). Then type "make c:/djgpp/bin/redir.exe" to generate the new
program. If you don't want to go to the bother, email me personally and
I'll send you the patched executable, or you can wait until the new
version is generated and download it from DJ's web site.
hth!
--
John M. Aldrich <fighteer AT cs DOT com>
* Anything that happens, happens.
* Anything that, in happening, causes something else to happen,
causes something else to happen.
* Anything that, in happening, causes itself to happen again, happens
again.
* It doesn't necessarily do it in chronological order, though.
--- Douglas Adams
--------------439434646885
Content-Type: text/plain; charset=us-ascii; name="REDIR.DIF"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="REDIR.DIF"
*** redir.c~ Wed Jul 12 04:06:50 1995
--- redir.c Wed Feb 19 21:04:32 1997
***************
*** 46,52 ****
{
/* ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8 */
fprintf(stderr, "Redir 1.0 Copyright (C) 1995 DJ Delorie (dj AT delorie DOT com) - distribute freely\n");
! fprintf(stderr, "NO WARRANTEE. This program is protected by the GNU General Public License.\n");
fprintf(stderr, "Usage: redir [-i file] [-o file] [-oa file] [-e file] [-ea file]\n");
fprintf(stderr, " [-eo] [-oe] [-x] [-t] command [args . . .]\n\n");
fprintf(stderr, " -i file redirect stdandard input from file\n");
--- 46,52 ----
{
/* ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8 */
fprintf(stderr, "Redir 1.0 Copyright (C) 1995 DJ Delorie (dj AT delorie DOT com) - distribute freely\n");
! fprintf(stderr, "NO WARRANTY. This program is protected by the GNU General Public License.\n");
fprintf(stderr, "Usage: redir [-i file] [-o file] [-oa file] [-e file] [-ea file]\n");
fprintf(stderr, " [-eo] [-oe] [-x] [-t] command [args . . .]\n\n");
fprintf(stderr, " -i file redirect stdandard input from file\n");
***************
*** 74,79 ****
--- 74,81 ----
int
main(int argc, char **argv)
{
+ char cmdline[4096]; /* hold command line to pass to system() */
+ int i;
if (argc < 2)
usage();
***************
*** 151,157 ****
argv++;
}
! rv = spawnvp(P_WAIT, argv[1], argv+1);
if (rv < 0)
fatal("Error attempting to run program %s\n", argv[1]);
--- 153,171 ----
argv++;
}
! /* The old method of calling spawnvp() breaks v2.01 programs that use
! * wildcards. To fix this, build the remaining arguments into one long
! * string to pass to system().
! */
! cmdline[0] = '\0';
! for ( i = 1; i < argc; i++ )
! {
! strcat( cmdline, argv[i] );
! if ( i < argc - 1 )
! strcat( cmdline, " " );
! }
! rv = system( cmdline );
!
if (rv < 0)
fatal("Error attempting to run program %s\n", argv[1]);
--------------439434646885--
- Raw text -