Skip to content
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

/usr/include/bits/resource.h exists but cannot be opened (breaks wait() / wait macros example ) #112

Open
angrave opened this issue Sep 12, 2015 · 1 comment

Comments

@angrave
Copy link
Contributor

angrave commented Sep 12, 2015

Steps to reproduce. Include the #includes that wait() requires:

#include <sys/types.h> 
#include <sys/wait.h>

I found resource.h using
ls -l /usr/include/bits
However it looks like it is "sticky"
(there are some other suspicious zero length files in there too e.g. user.h)

Switching to root. rm-ing and touch-ing resource.h 'fixes' the original problem.
i.e. We can now compile and run the following example -

#include <stdio.h>
#include <unistd.h>
#include <sys/types.h> 
#include <sys/wait.h>

pid_t childid;
void child() {
    // ______ Make the alarm go in 1 second
    alarm(1);
    sleep(2);
    puts("I'm the child exiting normally");
    exit(0);
}

void parent() {
    int status;
    waitpid(childid, &status, 0);
    if(WIFSIGNALED (status)) {
        printf("Child exited due to signal %d\n", WTERMSIG(status));
        if(WTERMSIG (status) == SIGALRM)
        puts("ALARM CLOCK");
    }else
    if( WIFEXITED(status)) {
        printf("Child exited with %d\n", WEXITSTATUS(status));
    }
}
int main() {
    printf("Hello world!\n");

    childid = fork ();
    if(childid >0) parent();
    else if(childid == 0) child();
    else puts ("fork failed"); // print error

    return 0;
}
@angrave
Copy link
Contributor Author

angrave commented Sep 12, 2015

Short term workaround suggestion: temporary scriptable fixes/hacks (e.g. su/rm/touch) can be added to the bootup java script easier than maintaining the linux disk image.

(Also would also be useful to make changes to the disk image more repeatable i.e. repeatable buildscript/patch listing that can be applied to vanilla jor1k image)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants