libnm-glib-aux: add nm_utils_get_process_exit_status_desc()

(cherry picked from commit 517852dccd)
This commit is contained in:
Beniamino Galvani 2021-05-27 08:02:56 +02:00
parent 3c96d4bb59
commit 227c5ca305
2 changed files with 21 additions and 0 deletions

View file

@ -6306,3 +6306,20 @@ nm_crypto_md5_hash(const guint8 *salt,
g_checksum_update(ctx, digest.ptr, NM_UTILS_CHECKSUM_LENGTH_MD5);
}
}
/*****************************************************************************/
char *
nm_utils_get_process_exit_status_desc(int status)
{
if (WIFEXITED(status))
return g_strdup_printf("exited with status %d", WEXITSTATUS(status));
else if (WIFSIGNALED(status))
return g_strdup_printf("killed by signal %d", WTERMSIG(status));
else if (WIFSTOPPED(status))
return g_strdup_printf("stopped by signal %d", WSTOPSIG(status));
else if (WIFCONTINUED(status))
return g_strdup("resumed by SIGCONT)");
else
return g_strdup_printf("exited with unknown status 0x%x", status);
}

View file

@ -2932,4 +2932,8 @@ void nm_crypto_md5_hash(const guint8 *salt,
guint8 * buffer,
gsize buflen);
/*****************************************************************************/
char *nm_utils_get_process_exit_status_desc(int status);
#endif /* __NM_SHARED_UTILS_H__ */