fopen("file","a")

Anton Alin-Adrian aanton at reversedhell.net
Wed May 26 05:26:04 PDT 2004


Hey folks.

	Running FreeBSD 4.9-RELEASE

	I am just wondering:

man fopen
---man---
      Upon successful completion fopen(), fdopen() and freopen() return a 
FILE pointer.  Otherwise, NULL is returned and the global variable errno is 
set to indicate the error.
---man---


However, the following snippet:

--snip--
	FILE *fp_queue;

	if ( (fp_queue=fopen(fqueue,"a"))  ==NULL);//will wait for locks
	{
		perror("fopen(fqueue,\"a\")");
		//exit(EXIT_FAILURE);
	}
--snip--


Has the following output:

--dump--

fopen(fqueue,"a"): Unknown error: 0

--dump--

	With that said, commenting out the exit() and using fputs() to write to 
the file works smoothly, data is written correctly, and no error is barked 
out. Same goes for fprintf().

	The snippet is so small, but I did learn that it's good to ask: am I doing 
something wrong, or is there something else wrong?

	Any suggestion is gratefully appreciated.

Regards,
-- 
Alin-Adrian Anton
Reversed Hell Networks
GPG keyID 0x1E2FFF2E (2963 0C11 1AF1 96F6 0030 6EE9 D323 639D 1E2F FF2E)
gpg --keyserver pgp.mit.edu --recv-keys 1E2FFF2E


More information about the freebsd-hackers mailing list