🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.os.linux.programacion
Article #10112

Re: Comprobar si un flujo de datos está cerrado

#10112
From: J.A. Gutierrez
Date: Tue, 26 Mar 2002 10:53
35 lines
2088 bytes
Jes�s �ngel <jpozdom@ribera.tel.uva.es> wrote:

: Para solucionarlo se me ha ocurrido hacer fptr_p=NULL despu�s de cerrar
: el flujo con fclose(3), pero quer�a saber si hay alguna forma de
: comprobar que un flujo ha sido cerrado previamente.

	Bueno, con ficheros abiertos mediante fopen, creo que no,
	pero bajando de nivel tienes:

n=open("/etc/motd", O_RDONLY);
printf("%d\n",n);
j=fcntl (4,F_GETFL);
if (j<0) perror("fcntl");
printf("%d\n",j);
j=fcntl (n,F_GETFL);
if (j<0) perror("fcntl");
printf("%d\n",j);
close(n);

3
fcntl: Bad file number
-1
0

	Por otra parte, puedes obtener el numero correspondiente a
	un FILE* mediante fileno(3); pero no se que hara si le
	pasas el correspondiente a un fichero ya cerrado.



-- 
PGP and other useless info at      \
http://www.cps.unizar.es/~spd/      \
finger://daphne.cps.unizar.es/spd    \       Timeo Danaos et dona ferentes
ftp://ivo.cps.unizar.es/pub/          \                         (Virgilio)   
Technical Details
Message-ID: <a7pk00$ib2$1@news.unizar.es>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed1.cidera.com!Cidera!news.comunitel.net!news.rediris.es!news.unizar.es!not-for-mail
References: <slrna9v1eq.f4d.jpozdom@sol.linux.bogus>

Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII
X-Google-Thread: f86c8,e3c48eb0627ce8a9
X-Google-Attributes: gidf86c8,public
X-Google-ArrivalTime: 2002-03-26 02:26:51 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed1.cidera.com!Cidera!news.comunitel.net!news.rediris.es!news.unizar.es!not-for-mail
From: "J.A. Gutierrez" <spd@daphne.cps.unizar.es>
Newsgroups: es.comp.os.linux.programacion
Subject: Re: Comprobar si un flujo de datos está cerrado
Date: 26 Mar 2002 10:53:52 GMT
Organization: Rank
Lines: 35
Message-ID: <a7pk00$ib2$1@news.unizar.es>
References: <slrna9v1eq.f4d.jpozdom@sol.linux.bogus>
NNTP-Posting-Host: daphne.cps.unizar.es
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: news.unizar.es 1017140032 18786 155.210.152.20 (26 Mar 2002 10:53:52 GMT)
X-Complaints-To: usenet@news.unizar.es
NNTP-Posting-Date: 26 Mar 2002 10:53:52 GMT
User-Agent: tin/1.4.5-20010409 ("One More Nightmare") (UNIX) (IRIX/6.2 (IP22))