refactor getrlimit/setrlimit code