File: wait.rst

package info (click to toggle)
fish 4.2.1-3.2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 35,976 kB
  • sloc: python: 6,972; javascript: 1,407; sh: 1,009; xml: 411; ansic: 230; objc: 78; makefile: 20
file content (56 lines) | stat: -rw-r--r-- 1,397 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
wait - wait for jobs to complete
================================

Synopsis
--------

.. synopsis::

    wait [-n | --any] [PID | PROCESS_NAME] ...

Description
-----------

.. only:: builder_man

          NOTE: This page documents the fish builtin ``wait``.
          To see the documentation on any non-fish versions, use ``command man wait``.

``wait`` waits for child jobs to complete.

If a *PID* is specified, the command waits for the job that the process with that process ID belongs to.

If a *PROCESS_NAME* is specified, the command waits for the jobs that the matched processes belong to.

If neither a pid nor a process name is specified, the command waits for all background jobs.

If the **-n** or **--any** flag is provided, the command returns as soon as the first job completes. If it is not provided, it returns after all jobs complete.

The **-h** or **--help** option displays help about using this command.

Example
-------

::

    sleep 10 &
    wait $last_pid

spawns ``sleep`` in the background, and then waits until it finishes.


::

    for i in (seq 1 5); sleep 10 &; end
    wait

spawns five jobs in the background, and then waits until all of them finish.


::

    for i in (seq 1 5); sleep 10 &; end
    hoge &
    wait sleep

spawns five ``sleep`` jobs and ``hoge`` in the background, and then waits until all ``sleep``\s finish, and doesn't wait for ``hoge``.