|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69421 getopt() fails when daemoning php file
Submitted: 2015-04-10 17:34 UTC Modified: 2015-04-14 20:07 UTC
From: nanocaiordo at gmail dot com Assigned: cmb (profile)
Status: Closed Package: CGI/CLI related
PHP Version: 5.4.39 OS: CloudLinux 6.6
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: nanocaiordo at gmail dot com
New email:
PHP Version: OS:


 [2015-04-10 17:34 UTC] nanocaiordo at gmail dot com
getopt() return false when daemonizing a PHP script, $argv is properly filled up with all the arguments but getopt() keeps returning false.

Calling the script without 'deamon --pidfile' does work, however something strange is that it outputs X-Powered-By and Content-type in CLI when getopt() fails.

Test script:

. /etc/rc.d/init.d/functions
daemon test.php -P Pdegub


#!/usr/bin/env php
ini_set('display_errors', 1);

Expected result:
sh ./

array(1) {
  string(6) "Pdebug"

Actual result:
sh ./

X-Powered-By: PHP/5.4.39
Content-type: text/html



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-04-11 11:13 UTC] nanocaiordo at gmail dot com
All good with PHP 5.5.23
 [2015-04-14 20:07 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2015-04-14 20:07 UTC]
As the problem apparently has been fixed in recent versions, and
PHP 5.4 is in the extented support phase (security fixes only), I'm
closing the ticket.

Thank you for the report, and for helping us make PHP better.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu Aug 05 02:01:23 2021 UTC