[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 802
  • Last Modified:

Running infinite while loop in PERL as a background process

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.

 regards,
--Srikanth
0
hSindhu
Asked:
hSindhu
  • 2
  • 2
1 Solution
 
gripeCommented:
Yes, this is a FAQ. Type:

perldoc -q daemon

at your command prompt.
0
 
manav_mathurCommented:
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.

Manav
0
 
ozoCommented:
Does the process attempt to read from the tty while in the loop?
0
 
ozoCommented:
perldoc -q background
0
 
manav_mathurCommented:
Use Proc::Daemon
see

http://perlmonks.thepen.com/31982.html

Manav


0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now