bug-mailfromd
Re: [Bug-mailfromd] How to handle defunct processes?
Hi Mehmet,
> I am using the below function to lookup items from postfix hash
> tables, but seeing a number of defunct postmap processes.
That's because you forgot to close the file handle.
> Is there a better way to handle this?
Yes, with a minimal number of modifications:
func get_postfix_map(string query, string table)
returns string
do
number fd
string cmd "/sbin/postmap -q %query /etc/postfix/%table"
set fd open("|&2>null: %cmd")
catch e_eof
do
close(fd)
return ""
done
set ret getline(fd)
close(fd)
return ret
done
Or, rearranging things a bit:
func get_postfix_map(string query, string table)
returns string
do
string cmd "/sbin/postmap -q %query /etc/postfix/%table"
string ret
set fd open("|&2>null: %cmd")
try
do
set ret getline(fd)
done
catch e_eof
do
set ret ""
done
close(fd)
return ret
done
Regards,
Sergey