core: don't call dup2 on negative fd after open() error

Also call close() only if open was succesful.
Reported by Coverity as CID #970991.
core: check return of getgroups()

When we pass 0 as size to getgroups() the number of additional
groups is return. If it returns error or 0 don't even try to
poke for additional groups.

Reported by Coverity as CID #970944.
core: check return of uwsgi_connect in uwsgi_opt_connect_and_read

Reported by Coverity as CID #970995.
plugins/python: check uwsgi_connect return code in uwsgi_python_harakiri

Reported by Coverity as CID #970996.
Merge pull request #133 from xrmx/coverity3

Fix "argument cannot be negative" errors reported by Coverity