c_types: handle errors from getgroups()/getgrouplist()

The most likely reason for  #236 is that either the getgroups() or getgrouplist() call fails, setting ngroups to -1.
ngroups is then used to size the `groups` Vec via `set_len(ngroups as uint)` which is obviously wrong in that case.