Re: why is this not a bug?
| From: | Rasmus Lerdorf | Date: | Thu, 13 Jul 2000 16:02:00 +0000 |
| Subject: | Re: why is this not a bug? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-6469@lists.php.net to get a copy of this message | ||
> which is unambiguously testing for values of non-zero for success and providing
> a zero value for failure... according to the code above, when the test for
> sendmail comes back as zero (indicating success), it should return an error, so
> how can what you assert be true?
As per the man page for popen()
RETURN VALUE
The popen function returns NULL if the fork(2) or pipe(2) calls
fail, or if it cannot allocate memory.
The pclose function returns -1 if wait4 returns an error, or some
other error is detected.
The PHP code checks for a non-zero (or false) and treats that as an error
condition. Since popen() returns -1 on an error the PHP code is correct.
-Rasmus