From owner-freebsd-questions Mon Aug 13 2:23:21 2001 Delivered-To: freebsd-questions@freebsd.org Received: from salmon.maths.tcd.ie (salmon.maths.tcd.ie [134.226.81.11]) by hub.freebsd.org (Postfix) with SMTP id A6B4537B401 for ; Mon, 13 Aug 2001 02:23:17 -0700 (PDT) (envelope-from iedowse@maths.tcd.ie) Received: from walton.maths.tcd.ie by salmon.maths.tcd.ie with SMTP id ; 13 Aug 2001 10:23:16 +0100 (BST) To: Gabriel Ambuehl Cc: questions@freebsd.org Subject: Re: Re[2]: write() failing.. In-Reply-To: Your message of "Mon, 13 Aug 2001 09:53:52 +0200." <138428502093.20010813095352@buz.ch> Date: Mon, 13 Aug 2001 10:23:16 +0100 From: Ian Dowse Message-ID: <200108131023.aa09406@salmon.maths.tcd.ie> Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG In message <138428502093.20010813095352@buz.ch>, Gabriel Ambuehl writes: >-----BEGIN PGP SIGNED MESSAGE----- > 58204 test_logfile CALL open(0x804f1f0,0x328,0xbfbffb80) > 58204 test_logfile NAMI "/var/log/some_log" > 58204 test_logfile RET open 3 ># so open returns with the correct file descriptor > 58204 test_logfile CALL write(0x3,0x8050010,0xb) ># write writes 0B bytes (which is about the length of hello world >;-)to file descriptor 3 > 58204 test_logfile RET write -1 errno 9 Bad file descriptor ># and the bad file descriptor bites Ah, you're missing the option O_WRONLY from the open flags: O_APPEND | O_CREAT | O_EXLOCK | O_NOFOLLOW should be O_WRONLY | O_APPEND | O_CREAT | O_EXLOCK | O_NOFOLLOW You are also missing the `mode' argument to open(), which is necessary when you specify O_CREAT. The "Bad file descriptor" error is documented on the `man 2 write' man page as [EBADF] d is not a valid descriptor open for writing. Ian To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message