-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cpm aborts on start with: "Failed to scan kernel release". #35
Comments
that's a scary kernel release.
int check_kernel_version()
{
struct utsname uts;
if(uname(&uts) == -1){
fprintf(stderr, "%s (%s, %d)\n",
_("Failed to discover kernel version."),
strerror(errno), errno);
}else if(!strncmp(uts.sysname, "Linux", 5)){
int maj,min,rel;
if(sscanf(uts.release, "%d.%d.%d", &maj, &min, &rel) != 3) {
fprintf(stderr, "%s (%s, %d)\n",
_("Failed to scan kernel release."),
strerror(errno),errno);
}else{
//fprintf(stdout, "kernel rel: %d.%d\n", maj, min);
if(maj > 2 ||
(maj == 2 && min > 6) ||
(maj == 2 && min == 6 && rel >= 9))
return 1;
}
}
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/utsname.h>
#include <sys/prctl.h>
#include <sys/ptrace.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
int main()
{
int status;
pid_t p, p0 = getpid();
p = fork();
if (p == -1) {
fprintf(stderr, "Could not fork: %s\n", strerror(errno));
_exit(1);
}
if (p == 0) {
if (prctl(PR_SET_DUMPABLE, 0, 0, 0, 0) != 0) {
fprintf(stderr, "Can not set child non dumpable\n");
_exit(1);
}
if (ptrace(PT_ATTACH, p0, 0, 0) != 0) {
// someone is already attached to us; shoot the parent in the head
fprintf(stderr, "Can't attach to parent!\n");
perror("foobar");
kill(p0, SIGKILL);
_exit(1);
}
printf("Attached to %d\n", p0);
while (1) {
if(ptrace(PT_SYSCALL, p0, 0, 0) == 0)
waitpid(p0, &status, 0);
if(errno == ESRCH && kill(p0, 0) == -1)
exit(0); // parent is dead
}
_exit(0);
}else { //twiddle thumbs
fprintf(stderr, "forked %d from %d\n", p, p0);
while(1){
sleep(1); // ZzzZZzZZ
}
}
} |
this should be fixed in 8c23b2e |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
cpm is unhappy with my kernel…
$ cpm
Failed to scan kernel release. (Success, 0)
Can't attach to parent!
[1] 23628 killed cpm
$ echo $?
137
$ uname -a
Linux turbotape 3.10-rc5-amd64 #1 SMP Debian 3.10
rc5-1exp1 (2013-06-11) x86_64 GNU/Linux$dpkg -l cpm
[...] cpm 0.28-1 [...]
The text was updated successfully, but these errors were encountered: