Output when killing a background process

I played a bit around with the Terminal and I observed something.

When I start and kill a background process, there is some kind of output. After I invoked the command to start the process the first message "[1] 13063" is directly displayed. However, after killing the process, the second message "[1]+ Beendet sleep 20" is displayed only after I issued some other command.

Does anyone know the reason why this happens? In my case, why is "[1]+ Beendet sleep 20" displayed after I executed ps?

user@host:~$ sleep 20 &
[1] 13063
user@host:~$ ps
  PID TTY          TIME CMD
12372 pts/0    00:00:00 bash
13063 pts/0    00:00:00 sleep
13064 pts/0    00:00:00 ps
user@host:~$ kill 13063
user@host:~$ ps
  PID TTY          TIME CMD
12372 pts/0    00:00:00 bash
13065 pts/0    00:00:00 ps
[1]+  Beendet                 sleep 20
user@host:~$

PS: I use a German Ubuntu, so "Beendet" means "Terminated".

Hi,

This is the default behaviour of bash. You can change it via the -b option (use set for this)

[root@host ~]# set -b
[root@host ~]# sleep 2 &
[1] 1306
[root@host ~]# [1]+  Done                    sleep 2

Thanks for the quick response.

I noticed in the mean time, that this is not the case on other systems. Here is the same example from the local computing cluster (which is a CentOS machine - but I am not 100% sure)

user@cluster user> sleep 10 &
[1] 31406
user@cluster user> kill 31406
user@cluster user>
[1]    Terminated                    sleep 10
user@cluster user> 

Does set -b not work there? It does for me on a CentOS 6.3 system:

# set +b
# sleep 2 &
[1] 1112
#
#
[1]+ Done                      sleep 2
# cat /etc/redhat-release 
CentOS release 6.3 (Final)
# set -b
# sleep 2 &
[1] 1342
# [1]+  Done                    sleep 2

With set, confusingly, - turns it on, + turns it off (which makes sense when you think about bash being invoked with those options set). You can invoke a shell with this behaviour turned on with

# bash -b