Untitled

 avatar
unknown
c_cpp
a year ago
577 B
6
Indexable
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/utsname.h>

int main() {
pid_t pid = fork();

if (pid == -1) {
// On error, -1 is returned
perror("fork failed");
exit(EXIT_FAILURE);
} else if (pid > 0) {
// Parent process
wait(NULL); // Wait for child to complete
} else {
// Child process
struct utsname unameData;
uname(&unameData);

printf("Kernel Version: %s\n", unameData.release);
printf("Compile Date: %s\n", __DATE__);
printf("Compile Time: %s\n", __TIME__);
exit(EXIT_SUCCESS);
}

return 0;
}
Editor is loading...
Leave a Comment