daveg
daveg

Reputation: 1211

Why won't 'system' call in perl return?

New, radical development on this. Go to the end and read.

perl 5, version 18, subversion 2 (v5.18.2) built for x86_64-linux-thread-multi
RH6

I have a perl script that makes a system() call which runs a tcsh script but, for one user, it won't return from that system call. The code is something like this...

#!/usr/bin/env perl
print "about to make the system call...\n";
$rv = system("tcsh aa.csh");
print "system call finished, return val = $rv\n";
exit;

And the aa.csh script...

echo "In shell script"     
mkdir foo
source someotherscript.csh
ln -s xxx yyy
echo "In shell script, about to exit"
exit

This script runs to completion for all users but one. He sees this...

about to make the system call...
In shell script
In shell script, about to exit

And it just hangs. If I hit ^C, it completes..

system call finished, return val = 2

Funny thing is, it prints the "In shell script, about to exit", with the very next step being "exit", but it just doesn't do it, at least not for this one user. All the commands that come before it are, in my mind, irrelevant because it reached this "about to exit" message. It appears that the ^C is interrupting the shell script (which won't exit) and returning to the perl script which proceeds to completion.

So my question has to do with learning why it hangs for this one guy. There's got to be something in his environment that's causing the problem but I don't know what. And what does a return value of "2" mean? May mean nothing because I interrupted with a ^C.

Thanks for any help

NEW DEVELOPMENT

This has nothing to do with perl. If the aa.csh script is just...

exit

And the user runs...

tcsh aa.csh

It hangs.

What's up with that?

Moderator, should this thread be deleted and should I repost (because this is so radically different) ?

Upvotes: 0

Views: 412

Answers (2)

daveg
daveg

Reputation: 1211

problem was a corrupted .history file.

Upvotes: 1

mob
mob

Reputation: 118625

Have him run

which exit

from a tcsh prompt. If it doesn't say something like

exit: shell built-in command

but rather something like

exit:   aliased to sleep 99999

then you've found your problem.

If exit is really the last line of your aa.csh script, then it is redundant, and you also try to use a version of the script that doesn't call exit at the end.

Upvotes: 0

Related Questions