Changeset 32323


Ignore:
Timestamp:
2018-08-06T19:38:44+12:00 (6 years ago)
Author:
ak19
Message:
  1. Dr Bainbridge fixed the way OpenOfficeConverter launched soffice in headless mode: it was incorrectly doing the 2 greater than ampersand 1 (redirecting stderr to stdout) before redirecting to /dev/null (and nul on windows). It has to be redirecting to /dev/null (and nul) before doing 2 greater than ampersand 1. The error had resulted in GLI failing to launch properly, with the call to pluginfo on the entire pluginlist blocking. SafeProcess was getting no data at all on the pluginfo process' stdout, not even eof/eos, so the BufferedReader.readLine() (and any read()) blocked resulting in that InputStreamGobbler.join() call not terminating.
Location:
gs2-extensions/open-office/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • gs2-extensions/open-office/trunk/src/perllib/plugins/OpenOfficeConverter.pm

    r32317 r32323  
    7373       
    7474        #my $cmd = "soffice --headless 2>&1"; # for linux and mac
    75         my $cmd = "soffice \"--accept=socket,host=$ENV{'SOFFICE_HOST'},port=$ENV{'SOFFICE_PORT'};urp;StarOffice.ServiceManager\" --headless 2>&1"; # for linux and mac
     75        my $cmd = "soffice \"--accept=socket,host=$ENV{'SOFFICE_HOST'},port=$ENV{'SOFFICE_PORT'};urp;StarOffice.ServiceManager\" --headless"; # basic shared command
    7676        my $status = 0;
    7777
     
    100100        $status = system("which soffice >nul 2>&1"); # which.exe should be in bin/windows
    101101        if ($status == 0) {
    102             $cmd = "start \"soffice process\" soffice \"--accept=socket,host=$ENV{'SOFFICE_HOST'},port=$ENV{'SOFFICE_PORT'};urp;StarOffice.ServiceManager\" --headless 2>&1";
    103             $cmd .= " >nul";
     102            $cmd = "start \"soffice process\" $cmd >nul 2>&1"; # order of >nul and 2>&1 matters, see below
    104103            #print STDERR "***** Tried to start-up OpenOffice with:\n$cmd\n";           
    105104        }
     
    110109        # automatically puts it in the background). 
    111110        # For Unix putting it in the background needs to be done
    112         # explicitly
    113 
    114         $cmd .= " >/dev/null &";
    115         }
     111        # explicitly by appending & to the end
     112
     113        # IMPORTANT! When redirecting output from 2>&1 to a file or null, >/dev/null (or >out.txt) should come BEFORE 2>&1
     114        # i.e. $some_cmd >out.txt 2>&1 and likewise $some_cmd >/dev/null 2>&1
     115        # Doing it in the wrong order further causes problems with SafeProcess when GLI starts up and calls pluginfo on the pluginslist:
     116        # SafeProcess blocks forever on read() from stdout of the process running pluginfo, because there's never data including no eof/eos
     117        # on the process' stdout when running this command in the wrong order.
     118        $cmd .=  " >/dev/null 2>&1 &";
     119        }
     120
     121        #print STDERR "@@@@ running: $cmd\n";
    116122       
    117123        $status = system($cmd) if ($status == 0);
Note: See TracChangeset for help on using the changeset viewer.