gio: Fix double-callback on cancellation with GSubprocess
gio: Fix double-callback on cancellation with GSubprocess

See bug #786456 for a detailed analysis of the situation which can cause
this (in summary, if a g_subprocess_wait_async() call is cancelled on a
GSubprocess which is already known to be dead).

The problem was that the GCancellable callback handler was
unconditionally returning a result for the GTask for
g_subprocess_wait_async(), even if that GTask had already returned a
result and the callback was being invoked after the GTask had been
removed from the pending_waits list.

Fix that by checking whether the GTask is still in the pending_waits
list before returning a result for it.

Thanks to Will Thompson for some very useful unit tests which reproduce
this (which will be pushed in the following commit).

Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://bugzilla.gnome.org/show_bug.cgi?id=786456

johne53/MB3Glib,johne53/MB3Glib,johne53/MB3Glib,johne53/MB3Glib,endlessm/glib,johne53/MB3Glib,endlessm/glib,johne53/MB3Glib,endlessm/glib,endlessm/glib,endlessm/glib