diff options
| author | Teddy Wing | 2020-10-11 00:38:29 +0200 |
|---|---|---|
| committer | Teddy Wing | 2020-10-11 00:38:29 +0200 |
| commit | 464d258b0cc29f889fa3e36d43022a0c6ec8a546 (patch) | |
| tree | aa77095bcc9f023ca15e74168932e12d5870e847 /Drop Serve/Server.m | |
| parent | cc4879875a35042f1440c4445dbac9ea1b26589e (diff) | |
| download | Drop-Serve-464d258b0cc29f889fa3e36d43022a0c6ec8a546.tar.bz2 | |
Server: Ensure the process is terminated before starting a new one
Just in case. Was getting a runtime exception occasionally and am still
not entirely sure why. It happened in the `[Server stop]` call.
Also check if the process is running before terminating it. Didn't read
about whether we're required to do this, but it seemed logical.
Diffstat (limited to 'Drop Serve/Server.m')
| -rw-r--r-- | Drop Serve/Server.m | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Drop Serve/Server.m b/Drop Serve/Server.m index 21da986..ad6146b 100644 --- a/Drop Serve/Server.m +++ b/Drop Serve/Server.m @@ -12,6 +12,8 @@ + (void)serveAtPath:(NSString *)path { + [self stop]; + _process = [[NSTask alloc] init]; [_process setCurrentDirectoryPath:path]; [_process setLaunchPath:@"/usr/bin/python"]; @@ -27,7 +29,10 @@ + (void)stop { - [_process terminate]; + if ([_process isRunning]) { + [_process terminate]; + } + [_process dealloc]; } |
