Skip to content
Snippets Groups Projects
Commit c71a6a68 authored by George Nachman's avatar George Nachman
Browse files

Make sure servers get killed on user-initiated quit. If we just HUP the shell...

Make sure servers get killed on user-initiated quit. If we just HUP the shell then the server won't notice until it becomes attached as an orphan on the next launch. Issue 6369
parent 868d531b
No related branches found
No related tags found
No related merge requests found
Loading
@@ -1794,7 +1794,7 @@ ITERM_WEAKLY_REFERENCEABLE
Loading
@@ -1794,7 +1794,7 @@ ITERM_WEAKLY_REFERENCEABLE
[self replaceTerminatedShellWithNewInstance]; [self replaceTerminatedShellWithNewInstance];
} else { } else {
_shouldRestart = YES; _shouldRestart = YES;
[_shell sendSignal:SIGKILL]; [_shell sendSignal:SIGKILL toServer:NO];
} }
} }
   
Loading
Loading
Loading
@@ -70,7 +70,7 @@ extern NSString *kCoprocessStatusChangeNotification;
Loading
@@ -70,7 +70,7 @@ extern NSString *kCoprocessStatusChangeNotification;
   
- (void)writeTask:(NSData*)data; - (void)writeTask:(NSData*)data;
   
- (void)sendSignal:(int)signo; - (void)sendSignal:(int)signo toServer:(BOOL)toServer;
   
// Cause the slave to receive a SIGWINCH and change the tty's window size. If `size` equals the // Cause the slave to receive a SIGWINCH and change the tty's window size. If `size` equals the
// tty's current window size then no action is taken. // tty's current window size then no action is taken.
Loading
Loading
Loading
@@ -828,8 +828,11 @@ static int MyForkPty(int *amaster,
Loading
@@ -828,8 +828,11 @@ static int MyForkPty(int *amaster,
[self.delegate threadedTaskBrokenPipe]; [self.delegate threadedTaskBrokenPipe];
} }
   
- (void)sendSignal:(int)signo { - (void)sendSignal:(int)signo toServer:(BOOL)toServer {
if (_serverChildPid != -1) { if (toServer && _serverPid != -1) {
DLog(@"Sending signal to server %@", @(_serverPid));
kill(_serverPid, signo);
} else if (_serverChildPid != -1) {
kill(_serverChildPid, signo); kill(_serverChildPid, signo);
} else if (_childPid >= 0) { } else if (_childPid >= 0) {
kill(_childPid, signo); kill(_childPid, signo);
Loading
@@ -931,7 +934,7 @@ static int MyForkPty(int *amaster,
Loading
@@ -931,7 +934,7 @@ static int MyForkPty(int *amaster,
- (void)stop { - (void)stop {
self.paused = NO; self.paused = NO;
[self stopLogging]; [self stopLogging];
[self sendSignal:SIGHUP]; [self sendSignal:SIGHUP toServer:NO];
[self killServerIfRunning]; [self killServerIfRunning];
   
if (fd >= 0) { if (fd >= 0) {
Loading
Loading
Loading
@@ -1370,7 +1370,10 @@ static iTermController *gSharedInstance;
Loading
@@ -1370,7 +1370,10 @@ static iTermController *gSharedInstance;
assert([iTermAdvancedSettingsModel runJobsInServers]); assert([iTermAdvancedSettingsModel runJobsInServers]);
for (iTermRestorableSession *restorableSession in _restorableSessions) { for (iTermRestorableSession *restorableSession in _restorableSessions) {
for (PTYSession *aSession in restorableSession.sessions) { for (PTYSession *aSession in restorableSession.sessions) {
[aSession.shell sendSignal:SIGHUP]; if (aSession.shell.serverPid != -1) {
[aSession.shell sendSignal:SIGKILL toServer:YES];
}
[aSession.shell sendSignal:SIGHUP toServer:YES];
} }
} }
} }
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment