1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-07 00:05:53 +02:00

Fixes a NPE when uname cannot be found in the path.

This commit is contained in:
Markus Schorn 2007-08-30 09:40:41 +00:00
parent caa71ea750
commit e1fd233516

View file

@ -8,6 +8,7 @@
* Contributors: * Contributors:
* IBM Corporation - Initial API and implementation (Corey Ashford) * IBM Corporation - Initial API and implementation (Corey Ashford)
* Anton Leherbauer (Wind River Systems) * Anton Leherbauer (Wind River Systems)
* Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.utils; package org.eclipse.cdt.utils;
@ -56,9 +57,14 @@ public final class Platform {
InputStreamReader inputStreamReader = new InputStreamReader(unameProcess.getInputStream()); InputStreamReader inputStreamReader = new InputStreamReader(unameProcess.getInputStream());
BufferedReader bufferedReader = new BufferedReader(inputStreamReader); BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
arch = bufferedReader.readLine(); String unameOutput= bufferedReader.readLine();
if (unameOutput != null) {
arch= unameOutput;
}
unameProcess.waitFor(); // otherwise the process becomes a zombie
} catch (IOException e) { } catch (IOException e) {
} catch (InterruptedException exc) {
Thread.currentThread().interrupt();
} }
} else if (arch.equals(org.eclipse.core.runtime.Platform.ARCH_X86)) { } else if (arch.equals(org.eclipse.core.runtime.Platform.ARCH_X86)) {
// Determine if the platform is actually a x86_64 machine // Determine if the platform is actually a x86_64 machine
@ -71,12 +77,13 @@ public final class Platform {
InputStreamReader inputStreamReader = new InputStreamReader(unameProcess.getInputStream()); InputStreamReader inputStreamReader = new InputStreamReader(unameProcess.getInputStream());
BufferedReader bufferedReader = new BufferedReader(inputStreamReader); BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
String unameOutput = bufferedReader.readLine(); String unameOutput = bufferedReader.readLine();
if (unameOutput.endsWith("64")) { //$NON-NLS-1$ if (unameOutput != null && unameOutput.endsWith("64")) { //$NON-NLS-1$
arch= org.eclipse.core.runtime.Platform.ARCH_X86_64; arch= org.eclipse.core.runtime.Platform.ARCH_X86_64;
} }
unameProcess.waitFor(); unameProcess.waitFor(); // otherwise the process becomes a zombie
} catch (IOException e) { } catch (IOException e) {
} catch (InterruptedException exc) { } catch (InterruptedException exc) {
Thread.currentThread().interrupt();
} }
} }
cachedArch= arch; cachedArch= arch;