[bash] 대기와 수면의 차이점

차이 무엇 waitsleep?



답변

wait프로세스가 완료되기를 기다립니다. sleep특정 시간 (초) 동안 대기합니다.


답변

wait는 BASH 내장 명령입니다. 보낸 사람 man bash:

    wait [n ...]
        Wait  for each specified process and return its termination sta-
        tus.  Each n may be a process ID or a job  specification;  if  a
        job  spec  is  given,  all  processes in that job's pipeline are
        waited for.  If n is not given, all currently active child  pro-
        cesses  are  waited  for,  and  the return status is zero.  If n
        specifies a non-existent process or job, the  return  status  is
        127.   Otherwise,  the  return  status is the exit status of the
        last process or job waited for.

sleep은 쉘 내장 명령이 아닙니다. 지정된 시간 동안 지연되는 유틸리티입니다.

sleep명령은 다양한 시간 단위의 대기를 지원할 수 있습니다. GNU coreutils 8.4 man sleep는 다음과 같이 말합니다.

    SYNOPSIS
        sleep NUMBER[SUFFIX]...

    DESCRIPTION
        Pause for NUMBER seconds.  SUFFIX may be s for seconds (the default),
        m for minutes, h for hours or d for days.  Unlike most  implemen-
        tations  that require NUMBER be an integer, here NUMBER may be an arbi-
        trary floating point number.  Given two or more  arguments,  pause  for
        the amount of time specified by the sum of their values.


답변

sleep 주어진 시간 (초) 동안 쉘을 지연시킵니다.

wait쉘이 주어진 작업을 기다립니다. 예 :

workhard &
[1] 27408
workharder &
[2] 27409
wait %1 %2

두 서브 프로세스가 완료 될 때까지 쉘을 지연시킵니다.


답변