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 520527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:09:16+00:00 2026-05-13T08:09:16+00:00

Problem: scriptA.cgi is sitting in an infinite loop and handling an open socket to

  • 0

Problem:
scriptA.cgi is sitting in an infinite loop and handling an open socket to a Flash client.
scriptB.cgi is called from the web, does what it needs to do and then needs to inform scriptA to send a message to the client.

Is this possible? I’m stuck on how to have scriptB identify the instance of scriptA that is sitting there with the socket connection, rather than launching one of its own.

all thoughts appreciated.

  • 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-13T08:09:16+00:00Added an answer on May 13, 2026 at 8:09 am

    If the communication needs are simple, this is a good application for signals.

    Edited to store process id from scriptA and read it in scriptB — scripts A and B have to agree on a name.

     # script B
     do_scriptB_job();
     if (open(my $PID_FILE, "<", "scriptA.pid.file")) {
       $process_id_for_scriptA = <$PID_FILE>;
       close $PID_FILE;
       kill 'USR1', $process_id_for_scriptA;  # makes scriptA run the SIGUSR1 handler
     }
    
    
     # script A
     open(my $PID_FILE, ">", "scriptA.pid.file");
     print $PID_FILE $$;
     close $PID_FILE;
     my $signaled = 0;
     $SIG{"USR1"} = \sub { $signaled = 1 } # simple SIGUSR1 handler, set a variable
     while ( in_infinite_loop ) {
         if ($signaled) {
             # this block runs only if SIGUSR1 was received 
             # since last time this block was run
             send_a_message_to_the_client();
             $signaled = 0;
         } else {
             do_something_else();
         }
     }
     unlink "scriptA.pid.file";   # cleanup
    

    When script A receives a SIGUSR1 signal, the script will be interrupted to run the USR1 signal handler, setting $signaled. The thread of execution will then resume and the script can use the information.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here are the problem scripts: This is from the HTML file: <script type=text/javascript> var
I just tracked down a problem where I had to close all open filehandles
I'm using HTTP POST to call a cgi script on a web server and
I have a web page that uses a Python cgi script to store requested
I have cgi script pulling search terms from an HTML form through CGI::Ajax .
I have a CGI script pulling bibliography data from a BibTeX file, building HTML
I have problem setting up CGI scripts to be run on Nginx, so far
I have problem with php script. The thing is that it shows me, that
I have problem with c# script who change user AD password, when try change
I have a problem with following script. It generates a list of places which

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.