The very fundamental problem is just, that the fact that the process/application/service has a PID/displays a window does not equal to the fact, that the service/application is ready to serve requests/the user.
This is why there are protocols like sd_notify [1] or readinessProbe [2] to determine the actual state of the launched service/process/application.