From cc2e00c656a34d4c472a25f929282c8fc63d0174 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Tue, 30 Nov 2010 00:16:06 +0000 Subject: =?UTF-8?q?=E2=80=A2=20Bundle=20commands=20-=20before=20closing=20?= =?UTF-8?q?a=20db=20doc=20window=20kill=20all=20commands=20associated=20to?= =?UTF-8?q?=20this=20doc=20-=20suppress=20an=20error=20message=20if=20a=20?= =?UTF-8?q?bash=20command=20was=20killed=20via=20code=209=20-=20added=20a?= =?UTF-8?q?=20temporary=20and=20preliminary=20table=20view=20to=20display?= =?UTF-8?q?=20command=20activities=20(double-click=20at=20TABLE=20INFO=20h?= =?UTF-8?q?eader=20to=20toggle=20and=20refresh=20it=20-=20only=20for=20tes?= =?UTF-8?q?ting=20purposes=20-=20it=20shows=20all=20commands=20started=20f?= =?UTF-8?q?rom=20that=20db=20doc=20and=20a=20General=20command=20names)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/SPDatabaseDocument.m | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'Source/SPDatabaseDocument.m') diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m index 23805b12..8ec6ad61 100644 --- a/Source/SPDatabaseDocument.m +++ b/Source/SPDatabaseDocument.m @@ -3655,6 +3655,7 @@ */ - (BOOL)parentTabShouldClose { + // If no connection is available, always return YES. Covers initial setup and disconnections. if(!_isConnected) return YES; @@ -3673,8 +3674,23 @@ return isSaved; } + // Terminate all running BASH commands + for(NSDictionary* cmd in [self runningBASHProcesses]) { + NSInteger pid = [[cmd objectForKey:@"pid"] intValue]; + NSTask *killTask = [[NSTask alloc] init]; + [killTask setLaunchPath:@"/bin/sh"]; + [killTask setArguments:[NSArray arrayWithObjects:@"-c", [NSString stringWithFormat:@"kill -9 -%ld", pid], nil]]; + [killTask launch]; + [killTask waitUntilExit]; + [killTask release]; + } + [[SPNavigatorController sharedNavigatorController] performSelectorOnMainThread:@selector(removeConnection:) withObject:[self connectionID] waitUntilDone:YES]; + // Note that this call does not need to be removed in release builds as leaks analysis output is only + // dumped if [[SPLogger logger] setDumpLeaksOnTermination]; has been called first. + [[SPLogger logger] dumpLeaks]; + // Return YES by default return YES; } @@ -3703,6 +3719,7 @@ [createTableSyntaxWindow orderOut:nil]; [[NSNotificationCenter defaultCenter] removeObserver:self]; [self setParentWindow:nil]; + } /** -- cgit v1.2.3