delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1997/09/23/07:29:49

Date: Tue, 23 Sep 1997 14:27:05 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Molnar Laszlo <molnarl AT cdata DOT tvnet DOT hu>
cc: DJGPP workers <djgpp-workers AT delorie DOT com>
Subject: Re: a little popen patch
In-Reply-To: <34278408.7C0FEDF3@cdata.tvnet.hu>
Message-ID: <Pine.SUN.3.91.970923141913.15252C-100000@is>
MIME-Version: 1.0

This change eliminates the code that adds a new node to the linked list. 
That list holds information from previous calls to `popen' that didn't
have a corresponding `pclose' yet.  So, if a program calls `popen' twice
(or more) in a row, the second call overwrites the info of the first.  Bad
idea...

Or did I miss something?

On Tue, 23 Sep 1997, Molnar Laszlo wrote:

> Just to save some bytes in libc.a....
> 
> Laszlo
> 
> 
> *** ~popen.c    Sun Aug 31 15:11:18 1997
> --- popen.c     Sat Sep 20 17:34:50 1997
> ***************
> *** 77,81 ****
>   popen (const char *cm, const char *md) /* program name, pipe mode */
>   {
> !   struct pipe_list *l1, *l2;
>   
>     /* make new node */
> --- 77,81 ----
>   popen (const char *cm, const char *md) /* program name, pipe mode */
>   {
> !   struct pipe_list *l1;
>   
>     /* make new node */
> ***************
> *** 90,107 ****
>     /* if empty list - just grab new node */
>     if (!pl)
> !     pl = l1;
> !   else
> !   {
> !     /* otherwise, find last node in list */
> !     ++(l1->fd);
> !     l2 = pl;
> !     while (l2->next)
> !     {
> !       ++(l1->fd);
> !       l2 = l2->next;
> !     };
> !     /* add new node to list */
> !     l2->next = l1;
> !   }
>   
>     /* stick in elements we know already */
> --- 90,95 ----
>     /* if empty list - just grab new node */
>     if (!pl)
> !     l1->next = pl;
> !   pl = l1;
>   
>     /* stick in elements we know already */
> 

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019