mirror of https://github.com/fairyglade/ly.git
fix kernel_log() and add error-checking
execl requires a full path to the executable, and the arguments begin with argv[0], not argv[1].
This commit is contained in:
parent
5a01a6e38f
commit
61c4152cff
15
src/utils.c
15
src/utils.c
|
|
@ -20,22 +20,29 @@ void kernel_log(int mode)
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
int status;
|
int status;
|
||||||
pid = fork();
|
pid = fork();
|
||||||
|
if(pid < 0) {
|
||||||
|
perror("fork");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
if(pid == 0)
|
if(pid == 0)
|
||||||
{
|
{
|
||||||
if(mode)
|
if(mode)
|
||||||
{
|
{
|
||||||
execl("dmesg", "-E", NULL);
|
execl("/bin/dmesg", "/bin/dmesg", "-E", NULL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
execl("dmesg", "-D", NULL);
|
execl("/bin/dmesg", "/bin/dmesg", "-D", NULL);
|
||||||
}
|
}
|
||||||
|
/* execl should not return */
|
||||||
exit(0);
|
perror("execl");
|
||||||
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
waitpid(pid, &status, 0);
|
waitpid(pid, &status, 0);
|
||||||
|
if(!WIFEXITED(status) || WEXITSTATUS(status))
|
||||||
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
char* trim(char* s)
|
char* trim(char* s)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue