The man page of bash (Special Parameters section) says:
? expands to the exit status of the most
recently executed foreground pipeline.
Nevertheless, background commands also modify the
value of this variable.
Example:
esoriano@omac:~$ false
esoriano@omac:~$ sleep 2 &
(wa
command1
returns a non-zero exit status. The return status of
AND and OR lists is the exit status of the last
command executed in the list.
In the following example:
esoriano@omac:~$ sleep 10 || echo hey
^Z
[5]+ Stopped sleep 10
hey
esoriano@omac:~$
there are two