Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 745923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T09:38:22+00:00 2026-05-14T09:38:22+00:00

The Disclaimer First of all, I know this question (or close variations) have been

  • 0

The Disclaimer

First of all, I know this question (or close variations) have been asked a thousand times. I really spent a few hours looking in the obvious and the not-so-obvious places, but there may be something small I’m missing.

The Context

Let me define the problem more clearly: I’m writing a newsletter app in which I want the actual sending process to be async. As in, user clicks “send”, request returns immediately and then they can check the progress in a specific page (via AJAX, for example). It’s written in your traditional LAMP stack.

In the particular host I’m using, PHP’s exec() and system() are disabled for security reasons, but Perl’s system functions (exec, system and backticks) aren’t. So my workaround solution was to create a “trigger” script in Perl that calls the actual sender via the PHP CLI, and redirects to the progress page.

Where I’m Stuck

The very line the calls the sender is, as of now:

system("php -q sender.php &");

Problem being, it’s not returning immediately, but waiting for the script to finish. I want it to run in the background and have the system call itself return right away. I also tried running a similar script in my Linux terminal, and in fact the prompt doesn’t show until after the script has finished, even though my test output doesn’t run, indicating it’s really running in the background.

What I already tried

  • Perl’s exec() function – same result of system().
  • Changing the command to: “php -q sender.php | at now”), hoping that the “at” daemon would return and that the PHP process itself wouldn’t be attached to Perl.
  • Executing the command ‘indirectly’: “/bin/sh -c ‘php -q sender.php &'” – still waits until sender.php is finished sending.
  • fork()’ing the process and executing the system call in the child (hopefully detached process) – same result as above

My test environment

Just to be sure that I’m not missing anything obvious, I created a sleeper.php script which just sleeps five seconds before exiting. And a test.cgi script that is like this, verbatim:

#!/usr/local/bin/perl
system("php sleeper.php &");
print "Content-type: text/html\n\ndone";

What should I try now?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T09:38:23+00:00Added an answer on May 14, 2026 at 9:38 am

    Essentially you need to ‘daemonize’ a process — fork off a child, and then entirely disconnect it from the parent so that the parent can safely terminate without affecting the child.

    You can do this easily with the CPAN module Proc::Daemon:

    use Proc::Daemon;
    # do everything you need to do before forking the child...
    
    # make into daemon; closes all open fds
    Proc::Daemon::Init();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Background / Disclaimer First of all, please feel free to skip this entirely if
I have been searching all over but I can't find any answer to this.
I will preface this question with the disclaimer that I know there are many
First of all, a disclaimer: I have experience in other languages, but am still
Disclaimer: I have no experience in signing the files and this is my first
Disclaimer: I have no prior experience in MVVM/MVC/MVP/MVWhatever, this is my very first try
First the disclaimer: I never learnt any programming in school, and just have to
Disclaimer: This is my first time writing unit tests...be gentle! :) I am trying
Disclaimer: this question is driven by my personal curiosity more than an actual need
First of all: this is not a duplicate of Delphi and SAPI . I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.