File: testUnlimitStacksize.pl

package info (click to toggle)
trinityrnaseq 2.11.0%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 417,528 kB
  • sloc: perl: 48,420; cpp: 17,749; java: 12,695; python: 3,124; sh: 1,030; ansic: 983; makefile: 688; xml: 62
file content (80 lines) | stat: -rwxr-xr-x 1,798 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env perl

use strict;
use warnings;
no strict 'subs';
#use BSD::Resource;

main: {
    
    print "\n\nBefore unlimit stack space:";
    system("bash -c ulimit -a");
    print "Attempting to unlimit stack space...";
    try_unlimit();

    

    
    print "After unlimit stack space: ";
    system("bash -c ulimit -a");
    system("ls");
    my $ls = `ls`;
    print "$ls\n";
    
    exit(0);
}


sub try_unlimit {
    #eval "
     #           use BSD::Resource;
      #  setrlimit(RLIMIT_STACK, RLIM_INFINITY, RLIM_INFINITY);";


    my $unset_stacksize_code = "use BSD::Resource;"
        . "setrlimit(RLIMIT_STACK, RLIM_INFINITY, RLIM_INFINITY);"
        . "my (\$soft, \$hard) = getrlimit(RLIMIT_STACK);"
        . "print \"stack_soft: \$soft, stack_hard: \$hard  \";"
        . "if (\$soft != -1) { die \"Couldn't unset stacksize\";}";


    eval($unset_stacksize_code);
    
    if( $@ ) {
        warn <<"EOF";
        
        $@
                
        Unable to set unlimited stack size. Please install the BSD::Resource
            Perl module to allow this script to set the stack size, or set it
            yourself in your shell before running Trinity (ignore this warning if
            you have set the stack limit in your shell). See the following URL for
            more information:

            http://trinityrnaseq.sourceforge.net/trinity_faq.html#ques_E

EOF
;
    }
    else {
    
            
        print "Successfully set unlimited stack size.\n";
        print "###################################\n\n";



    }
    
    ## verify
    print "\n\n";
    eval("use BSD::Resource;"
         ."my (\$soft, \$hard) = getrlimit(RLIMIT_STACK);"
         ."print \"Verifying: stack_soft: \$soft, stack_hard: \$hard  \";"  );
    
    

        
    return;
}