If pg_background_launch function is called from non-interactive session, i.e.
psql -c "pg_background_launch(...)" then pg_background is failed with "Unable to map dynamic shared memory segment" message. It happens because dynamic shared memory segment is already destroyed by terminated backend. dsm_pin_mapping is not able to prevent it, because it is not incrementing reference counter. The problem can be solved by using dsm_pin_segment, but correspondent dsm_unpin_segment is available only in Postgres 10.
I wonder if there are plans to port pg_background to 10 (it requires minimal efforts: specify background worker function not by address but by name) and is it better to use pin/unpin segment to let background worker correctly start even if host backend already terminates.