caffeinate に -d フラグを追加し、ディスプレイスリープ中の App Nap によるプロセス凍結を防止

This commit is contained in:
nrslib 2026-02-08 19:36:19 +09:00
parent 3533946602
commit 8d760c1fc7
2 changed files with 5 additions and 3 deletions

View File

@ -71,7 +71,7 @@ describe('preventSleep', () => {
expect(spawn).toHaveBeenCalledWith(
'/usr/bin/caffeinate',
['-i', '-w', String(process.pid)],
['-di', '-w', String(process.pid)],
{ stdio: 'ignore', detached: true }
);
expect(mockChild.unref).toHaveBeenCalled();

View File

@ -8,7 +8,9 @@ const log = createLogger('sleep');
let caffeinateStarted = false;
/**
* takt実行中のmacOSアイドルスリープを防止する
* takt実行中のmacOSアイドルスリープおよびディスプレイスリープを防止する
* -d: ディスプレイスリープ防止App Nap
* -i: アイドルスリープ防止
* -s AC電源が必要なため
*/
export function preventSleep(): void {
@ -26,7 +28,7 @@ export function preventSleep(): void {
return;
}
const child = spawn(caffeinatePath, ['-i', '-w', String(process.pid)], {
const child = spawn(caffeinatePath, ['-di', '-w', String(process.pid)], {
stdio: 'ignore',
detached: true,
});