Running infinite while loop in PERL as a background process

Posted on 2004-11-24
Last Modified: 2008-02-07
Hi Folks!

I have a script which has an infinite while loop(while(1) { ........}) acts as a control logic for
all the activities with in the script  and is running on a unix platform.

Whenever I run this program,  due to the infinite loop, the terminal window will be under
the control of the script(window will be grabbed by the script) and the user will  not be able to
use that particular terminal until the jobs gets over.

If run this script with an '&' option , it produces 'suspended tty' at the command prompt
and the process doesn't take place.

Is there any option in perl to run the infinite loops as a background process on unix?
( except cron jobs)

If anybody knows the answers please respond asap and your feedback will be
highly appriciated.

Question by:hSindhu
    LVL 13

    Accepted Solution

    Yes, this is a FAQ. Type:

    perldoc -q daemon

    at your command prompt.
    LVL 16

    Expert Comment

    Dunno about PERL, but did you try nohup?

    This looks like a daemon process to me.
    In theory, its design should fork off child which dosnt have any
    terminal attached. The parent then dies off and init becomes parent
    of the process. Hence the process lives indefinitely.

    LVL 84

    Expert Comment

    Does the process attempt to read from the tty while in the loop?
    LVL 84

    Expert Comment

    perldoc -q background
    LVL 16

    Expert Comment

    Use Proc::Daemon



    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
    Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now