Perl Error No Child Processes
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up “No child processes” error in perl up vote 3 down vote favorite 3 I have a Perl script which invokes the sqlldr and loads data to a table from a flat file. Now, my problem is, even though the sqlldr loads the table fine it is returning exit code as -1(got by using $?), when i tried using $! it says No child processes. I'm executing this script by using sudo command sudo -u
a daemon on a RHEL box and does just about everything correctly. It's job is to scan a hash of jobs every 15s to see if there are any new ones that need to be performed. Each time a new job is found, this script forks off a child to perform the necessary task. Prior to forking off the child, it runs a utility called 'cleanXML' which is designed to remove invalid characters from an XML file. I use system to call the utility. For some reason, the return code is 'No child processes'. But, the thing is, it has absolutley no problem forking just a few lines later... You don't check the return code from http://stackoverflow.com/questions/5606668/no-child-processes-error-in-perl system, so you mean something else. I assume that you mean $! says that. What I think is happening is that when the system fails, it is setting $? to -1, but it does not touch $!. So the contents of it are invalid for you and represent something else (like some old wait from elsewhere). Here's an example: $ cat /tmp/systest #!/usr/bin/perl -w use strict; my $prog = '/tmp/noexist'; system($prog); print "Error vars are $? and http://coding.derkeiler.com/Archive/Perl/comp.lang.perl.misc/2007-03/msg00118.html $!\n"; wait; system($prog); print "Error vars are $? and $!\n"; $ perl /tmp/systest Can't exec "/tmp/noexist": No such file or directory at /tmp/perl line 5. Error vars are 65280 and Can't exec "/tmp/noexist": No such file or directory at /tmp/perl line 8. Error vars are 65280 and No child processes The only difference between the two invocations is that the wait() put something in $! which was picked up later. It's not associated with the failed fork/exec from system. So my question is... what's going on!?! If I think about it, the return value of -1 means that after the hidden fork() that system() performs, the parent process couldn't find any child processes, which means either that the fork() didn't work or that the child died before the parent process could proceed... is that feasible? Most likely is that the system is failing because the code you're trying to run is not executable (pathname, permissions, etc.) -- Darren Dunham ddunham@xxxxxxxx Senior Technical Consultant TAOS http://www.taos.com/ Got some Dr Pepper? San Francisco, CA bay area < This line left intentionally blank to confuse you. > . Follow-Ups: Re: Why 'No child processes' after a system() call From: danrumney References: Why 'No child processes' after a system() call From: danrumney Prev by Date: Re: Q on regex of LWP::Simple data Next by Date: Re: Why 'No child processes' after a
below) that is driving me nuts. It runs as a daemon on a RHEL box and does just about everything correctly. It's job is to scan a hash of jobs every 15s to see if there are any new ones that http://www.thecodingforums.com/threads/why-no-child-processes-after-a-system-call.902088/ need to be performed. Each time a new job is found, this script forks off a child to perform the necessary task. Prior to forking off the child, it runs a utility called 'cleanXML' which is designed to remove invalid characters from https://access.redhat.com/solutions/369273 an XML file. I use system to call the utility. For some reason, the return code is 'No child processes'. But, the thing is, it has absolutley no problem forking just a few lines later... So my question is... what's going perl error on!?! If I think about it, the return value of -1 means that after the hidden fork() that system() performs, the parent process couldn't find any child processes, which means either that the fork() didn't work or that the child died before the parent process could proceed... is that feasible? Any other hypotheses would be warmly welcomed Thanks, Dan #!/usr/bin/perl use strict; use svcNav::svcView; # Custom module use svcNav::svcControl; # Custom module use Data:umper; use diagnostics; sub message(@); sub error(@); sub wall(@); my $access_log perl error no = "/var/log/svcObjectBrowserJobs.log"; my $error_log = "/var/log/svcObjectBrowserJobs.error.log"; open STDIN, '/dev/null' or die "Can't read /dev/null: $!"; open STDOUT, ">>$access_log" or die "Can't write to $access_log: $!"; open STDERR, ">>$error_log" or die "Can't write to $error_log: $!"; # Change to root so that unmounting filesystems will be possible chdir '/'; my $canCleanXML = "no"; my $xmlCleaner = "/root/cleanXML"; #Custom utility that clears invalid chars from an XML file # Check to see if we can execute the cleanXML script if ( -x $xmlCleaner ) { $canCleanXML = "yes"; } wall( "objectBrowser daemon started PID:" . $$ ); wall( "XML Cleaning will", ( $canCleanXML eq "yes" ) ? " " : " not ", "be performed"); # # In order to reset this daemon, simply put a job of type "reset" in the queue # The dameon will reset once there are no more running jobs my $endLoop = "no"; my $runningJobs = 0; my $resetJobId = 0; # Main loop do { # Scan the job queue no more often than every 15s # The period may be longer, depending on how many jobs get started in this # pass through sleep 15; my $jobs = svcView::getJobs(); # get a hash of 'jobs' # Throw out the jobs that have already failed and # Count the running jobs $runningJobs = 0; my $nonFailedJobs = {}; foreach my $jobKey ( keys %$jobs ) { if ( $jobs->{$jobKey}->{'type'} eq "reset" ) { if ($endLoop eq "no") { wall("Reset request received"); $resetJobId = $jobKey;
Red Hat Certificate System Red Hat Satellite Subscription Asset Manager Red Hat Update Infrastructure Red Hat Insights Ansible Tower by Red Hat Cloud Computing Back Red Hat CloudForms Red Hat OpenStack Platform Red Hat Cloud Infrastructure Red Hat Cloud Suite Red Hat OpenShift Container Platform Red Hat OpenShift Online Red Hat OpenShift Dedicated Storage Back Red Hat Gluster Storage Red Hat Ceph Storage JBoss Development and Management Back Red Hat JBoss Enterprise Application Platform Red Hat JBoss Data Grid Red Hat JBoss Web Server Red Hat JBoss Portal Red Hat JBoss Operations Network Red Hat JBoss Developer Studio JBoss Integration and Automation Back Red Hat JBoss Data Virtualization Red Hat JBoss Fuse Red Hat JBoss A-MQ Red Hat JBoss BPM Suite Red Hat JBoss BRMS Mobile Back Red Hat Mobile Application Platform Services Back Consulting Technical Account Management Training & Certifications Red Hat Enterprise Linux Developer Program Support Get Support Production Support Development Support Product Life Cycle & Update Policies Knowledge Search Documentation Knowledgebase Videos Discussions Ecosystem Browse Certified Solutions Overview Partner Resources Tools Back Red Hat Insights Learn More Red Hat Access Labs Explore Labs Configuration Deployment Troubleshooting Security Additional Tools Red Hat Access plug-ins Red Hat Satellite Certificate Tool Security Back Product Security Center Security Updates Security Advisories Red Hat CVE Database Security Labs Resources Overview Security Blog Security Measurement Severity Ratings Backporting Policies Product Signing (GPG) Keys Community Back Discussions Red Hat Enterprise Linux Red Hat Virtualization Red Hat Satellite Customer Portal Private Groups All Discussions Start a Discussion Blogs Customer Portal Red Hat Product Security Red Hat Access Labs Red Hat Insights All Blogs Events Customer Events Red Hat Summit Stories Red Hat Subscription Benefits You Asked. We Acted. Open Source Communities Subscriptions Downloads Support Cases Account Back Log In Register Red Hat Account Number: Account Details Newsletter and Contact Preferences User Management Account Maintenance My Profile Notifications Help Log Out Language Back English español Deutsch italiano 한국어 français 日本語 português 中文 (中国) русский Customer Portal Search Products & Services Back View All Products Infrastructure and Management Back Red Hat Enterprise Linux Red Hat Virtualization Red Hat Identity Management Red Hat Directory Server Red Hat Certi