Untitled

mail@pastecode.io avatar
unknown
c_cpp
22 days ago
577 B
2
Indexable
Never
#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;
}
Leave a Comment