Skip to content

Sleep

무한 대기 상태

$ sleep inf

SIGTERM을 신호를 확인하기 전 까지 무한정 기다리게 된다. sleep 1을 루프문으로 사용할 경우 매초마다 CPU를 깨우므로 이상적이지 않습니다.

Examples

TypeScript Promise

/**
 * Creates a promise that resolves to null after some time.
 */
export async function sleep(time: number): Promise<null> {
  return await new Promise((accept) => {
    setTimeout(() => accept(null), time)
  })
}