Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(552)

Side by Side Diff: chrome/browser/mac/dock.mm

Issue 2108703002: mac: Send SIGTERM instead of SIGHUP to restart Dock (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "chrome/browser/mac/dock.h" 5 #import "chrome/browser/mac/dock.h"
6 6
7 #include <ApplicationServices/ApplicationServices.h> 7 #include <ApplicationServices/ApplicationServices.h>
8 #include <CoreFoundation/CoreFoundation.h> 8 #include <CoreFoundation/CoreFoundation.h>
9 #import <Foundation/Foundation.h> 9 #import <Foundation/Foundation.h>
10 #include <signal.h> 10 #include <signal.h>
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 return nil; 116 return nil;
117 } 117 }
118 118
119 NSString* path = [url path]; 119 NSString* path = [url path];
120 [app_paths addObject:path]; 120 [app_paths addObject:path];
121 } 121 }
122 122
123 return app_paths; 123 return app_paths;
124 } 124 }
125 125
126 // Restart the Dock process by sending it a SIGHUP. 126 // Restart the Dock process by sending it a SIGTERM.
127 void Restart() { 127 void Restart() {
128 // Doing this via launchd using the proper job label is the safest way to 128 // Doing this via launchd using the proper job label is the safest way to
129 // handle the restart. Unlike "killall Dock", looking this up via launchd 129 // handle the restart. Unlike "killall Dock", looking this up via launchd
130 // guarantees that only the right process will be targeted. 130 // guarantees that only the right process will be targeted.
131 pid_t pid = base::mac::PIDForJob("com.apple.Dock.agent"); 131 pid_t pid = base::mac::PIDForJob("com.apple.Dock.agent");
132 if (pid <= 0) { 132 if (pid <= 0) {
133 return; 133 return;
134 } 134 }
135 135
136 // Sending a SIGHUP to the Dock seems to be a more reliable way to get the 136 // Sending a SIGTERM to the Dock seems to be a more reliable way to get the
137 // replacement Dock process to read the newly written plist than using the 137 // replacement Dock process to read the newly written plist than using the
138 // equivalent of "launchctl stop" (even if followed by "launchctl start.") 138 // equivalent of "launchctl stop" (even if followed by "launchctl start.")
139 // Note that this is a potential race in that pid may no longer be valid or 139 // Note that this is a potential race in that pid may no longer be valid or
140 // may even have been reused. 140 // may even have been reused.
141 kill(pid, SIGHUP); 141 kill(pid, SIGTERM);
142 } 142 }
143 143
144 } // namespace 144 } // namespace
145 145
146 AddIconStatus AddIcon(NSString* installed_path, NSString* dmg_app_path) { 146 AddIconStatus AddIcon(NSString* installed_path, NSString* dmg_app_path) {
147 // ApplicationServices.framework/Frameworks/HIServices.framework contains an 147 // ApplicationServices.framework/Frameworks/HIServices.framework contains an
148 // undocumented function, CoreDockAddFileToDock, that is able to add items 148 // undocumented function, CoreDockAddFileToDock, that is able to add items
149 // to the Dock "live" without requiring a Dock restart. Under the hood, it 149 // to the Dock "live" without requiring a Dock restart. Under the hood, it
150 // communicates with the Dock via Mach IPC. It is available as of Mac OS X 150 // communicates with the Dock via Mach IPC. It is available as of Mac OS X
151 // 10.6. AddIcon could call CoreDockAddFileToDock if available, but 151 // 10.6. AddIcon could call CoreDockAddFileToDock if available, but
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 330
331 // Rewrite the plist. 331 // Rewrite the plist.
332 [dock_plist setObject:persistent_apps forKey:kDockPersistentAppsKey]; 332 [dock_plist setObject:persistent_apps forKey:kDockPersistentAppsKey];
333 [user_defaults setPersistentDomain:dock_plist forName:kDockDomain]; 333 [user_defaults setPersistentDomain:dock_plist forName:kDockDomain];
334 334
335 Restart(); 335 Restart();
336 return IconAddSuccess; 336 return IconAddSuccess;
337 } 337 }
338 338
339 } // namespace dock 339 } // namespace dock
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698