mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-04 13:50:55 +00:00
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@8977 72102866-910b-0410-8b05-ffd578937521
45 lines
1.1 KiB
Objective-C
45 lines
1.1 KiB
Objective-C
#include <Foundation/NSAutoreleasePool.h>
|
|
#include <Foundation/NSProcessInfo.h>
|
|
#include <Foundation/NSTask.h>
|
|
|
|
int
|
|
main()
|
|
{
|
|
id pool;
|
|
NSDictionary *env;
|
|
NSTask *task;
|
|
NSData *d;
|
|
|
|
pool = [[NSAutoreleasePool alloc] init];
|
|
|
|
#ifdef __MINGW__
|
|
task = [NSTask launchedTaskWithLaunchPath: @"C:\\WINDOWS\\COMMAND\\MEM.EXE"
|
|
arguments: nil];
|
|
#else
|
|
task = [NSTask launchedTaskWithLaunchPath: @"/bin/ls"
|
|
arguments: nil];
|
|
#endif
|
|
[task waitUntilExit];
|
|
printf("Exit status - %d\n", [task terminationStatus]);
|
|
|
|
[pool release];
|
|
pool = [[NSAutoreleasePool alloc] init];
|
|
|
|
task = [NSTask new];
|
|
env = [[[[NSProcessInfo processInfo] environment] mutableCopy] autorelease];
|
|
[task setEnvironment: env];
|
|
[task setLaunchPath: @"/bin/sh"];
|
|
[task setArguments: [NSArray arrayWithObjects: @"-c", @"echo $PATH", nil]];
|
|
if ([task usePseudoTerminal] == NO)
|
|
printf("Argh - unable to use pseudo terminal\n");
|
|
[task launch];
|
|
d = [[task standardOutput] availableData];
|
|
NSLog(@"Got PATH of '%*s'", [d length], [d bytes]);
|
|
|
|
[task waitUntilExit];
|
|
[task release];
|
|
[pool release];
|
|
|
|
exit(0);
|
|
}
|
|
|