I'm redirecting the stdout of php process(cli mode) to a file.
Why exit code is 0 when disk is full.
I can reappear this problem in php 7.1/5.6/5.4 and both in macos and centos.
leojins-MacBook-Pro-2:Downloads leojin$ php test.php > /Volumes/disk_test/test.log
leojins-MacBook-Pro-2:Downloads leojin$ echo $?
0
leojins-MacBook-Pro-2:Downloads leojin$ df -h
Filesystem Size Used Avail Capacity iused ifree %iused Mounted on
/dev/disk1s1 233Gi 27Gi 205Gi 12% 580000 9223372036854195807 0% /
devfs 189Ki 189Ki 0Bi 100% 654 0 100% /dev
/dev/disk1s4 233Gi 1.0Gi 205Gi 1% 1 9223372036854775806 0% /private/var/vm
map -hosts 0Bi 0Bi 0Bi 100% 0 0 100% /net
map auto_home 0Bi 0Bi 0Bi 100% 0 0 100% /home
/dev/disk2s1 95Mi 93Mi 1.5Mi 99% 96 9223372036854775711 0% /Volumes/disk_test
Following is the content of test.php
:
<?php
$i = 0;
while (true) {
echo "php:" . $i . "\n";
$i++;
}
When i use python, it exit with 1 as expected.
leojins-MacBook-Pro-2:Downloads leojin$ python test.py > /Volumes/disk_test/test.log
Traceback (most recent call last):
File "test.py", line 3, in <module>
print 'python:' + str(i)
IOError: [Errno 28] No space left on device
leojins-MacBook-Pro-2:Downloads leojin$ echo $?
1
Following is the content of test.py
:
i = 0
while True:
print 'python:' + str(i)
i = i + 1
I also tried php -d implicit_flush=0
and python -u
, there is no difference.