Re^3: In a multithreading Perl Code How to Exit one thread while outher thread keeps running ?
by Corion (Patriarch) on Jul 06, 2009 at 13:02 UTC
|
So you mean you want to keep part of your program running yet signal success to the calling program? That's not possible with threads. You will need to daemonize your program so it runs in the background.
| [reply] |
|
|
So you mean you want to keep part of your program running yet signal success to the calling program? That's not possible with threads.
Considering that variables can be shared in threads (which is about the only reason to use threads - if you don't need to communicate between threads, you might as well fork), returning status should be easy. Note that most implementation, sharing variables is the default in threads, but Perl does the opposite, but you can mark variables as shared.
| [reply] |
|
|
I've interpreted the problem as returning an exit status of 0 to the calling process, which is hard as long as you've got threads running, as a process consists of its threads, at least under Windows. I don't know if POSIX is different - at least POSIX threads share the same ID-space as processes, so the main thread might exit there and still leave other threads running, but I doubt that.
| [reply] |
|
|
|
|
|
|
Thanks Corion,
Can you throw some more light on "daemonize". Since now you got my exact requirement.
| [reply] |
|
|
| [reply] |
Re^3: In a multithreading Perl Code How to Exit one thread while outher thread keeps running ?
by massa (Hermit) on Jul 06, 2009 at 12:50 UTC
|
You should enclose your code in <code></code> tags, so we could try to understand better what are you trying to do...
[]s, HTH, Massa (κς,πμ,πλ)
| [reply] [d/l] |
|
|
Objective:
When we are executing our Perl script by using Autosys tool (Job Scheduling tool). It is not able to recognise Expect.pm which I used in my Perl code. And I am getting the below error.
Can't call method "expect" on an undefined value at /xxxx/bin/run_EMCTSftpPutEclerxFile.pl line 18.
Expect is not working go
But when I am executing it manually It works flawlesly. Pl. find my Perl script below:
1 #!/opt/perl/5.8.0/bin/perl
2 #ident "%W%"
3
4 use Expect;
5
6 $xxxx_FTP_HOST="xxxxx";
7 $xxxx_FTP_USER="xxxx";
8 $xxxx_FTP_PASS="xxxxx";
9 $xxxxx_FTP_LDIR="/opt/ftp/pub/outgoing";
10 $xxxxx_FTP_LFILE=$ARGV[0];
11 $timeout = 10;
12 $command = 'sftp';
13
14 $params = ("$xxxxxR\@$xxxxX_FTP_HOST");
15
16 $exp=Expect->spawn($command, $params) or print "Expect is not working go \n";
17
18 $exp->expect($timeout, "Password:");
19
20 $exp->send("$Exxxxx_FTP_PASS\n");
21
22 $exp->expect($timeout, "sftp>");
23
24 $exp->send("binary\r");
25
26 $exp->expect($timeout, "sftp>");
27
28 $exp->send("put $xxxxxX_FTP_LDIR/$xxxxx_FTP_LFILE \n");
29
30 $exp->expect($timeout, "sftp>");
31
32 $exp->send("bye\n");
33
34 $exp->soft_close();
| [reply] |
|
|
Even now, you can edit your original post and reformat it to be more legible. :-D No need to wait for the Future. :-D Others searching the Monastery can benefit from understanding your question and connecting it to the answer that seemed to satisfy it (below). Ok?
[]s, HTH, Massa (κς,πμ,πλ)
| [reply] |