PR#5371: a partial patch by Edwin Török to fix the FreeBSD failure

It may be interesting to backport the FreeBSD fix on the standalone version.