diff -ruNp reuse-4.2.2/source/db/revisions reuse/source/db/revisions --- reuse-4.2.2/source/db/revisions 2005-11-07 13:49:36.000000000 +0300 +++ reuse/source/db/revisions 2006-01-26 23:35:51.000000000 +0300 @@ -576,3 +576,5 @@ unix/stream_io.c 6 9 1927650 ./include/reuse/Sets.h 6 8 315277 ./include/reuse/osdeps.h 6 22 214306 unix/exec.c 6 35 3451533 +unix/exec.c 6 36 3508988 +win32/os_env.c 1 5 496541 diff -ruNp reuse-4.2.2/source/db/versions reuse/source/db/versions --- reuse-4.2.2/source/db/versions 2005-11-09 10:04:49.000000000 +0300 +++ reuse/source/db/versions 2006-01-26 23:35:52.000000000 +0300 @@ -98,3 +98,4 @@ 1903 4.2 0 2005/08/08 1916 4.2 1 2005/10/27 1917 4.2 2 2005/11/09 +1919 4.2 3 2006/01/26 diff -ruNp reuse-4.2.2/source/NEWS reuse/source/NEWS --- reuse-4.2.2/source/NEWS 2005-11-09 10:02:39.000000000 +0300 +++ reuse/source/NEWS 2006-01-26 23:35:06.000000000 +0300 @@ -1,4 +1,9 @@ -$Id: NEWS,v 6.14 2005/11/09 07:02:39 cher Exp $ +$Id: NEWS,v 6.15 2006/01/26 20:35:06 cher Exp $ + +Reuse 4.2.3 (20060126) +====================== +Support for the non-standard kernel features provided by the -cher +kernel patches for 2.6 kernels. Reuse 4.2.2 (20051109) ====================== diff -ruNp reuse-4.2.2/source/unix/ChangeLog reuse/source/unix/ChangeLog --- reuse-4.2.2/source/unix/ChangeLog 2005-10-27 13:07:28.000000000 +0400 +++ reuse/source/unix/ChangeLog 2006-01-26 23:35:27.000000000 +0300 @@ -1,3 +1,12 @@ +2006-01-26 Alexander Chernov + + * exec.c: support for extra kernel features patch for 2.6 kernels. + +2005-11-07 Alexander Chernov + + * exec.c: + (linux_set_fix_flag) timelimit check is disabled for linux 2.6. + 2005-10-27 Alexander Chernov * exec.c: (task_PrintArgs) Fixes for 64-bit platforms. @@ -845,4 +854,4 @@ Fri Nov 10 11:00:50 1995 Alexander Cher * System.c: Initial revision END - # $Id: ChangeLog,v 6.31 2005/10/27 09:07:28 cher Exp $ + # $Id: ChangeLog,v 6.32 2006/01/26 20:35:27 cher Exp $ diff -ruNp reuse-4.2.2/source/unix/exec.c reuse/source/unix/exec.c --- reuse-4.2.2/source/unix/exec.c 2005-11-07 13:47:25.000000000 +0300 +++ reuse/source/unix/exec.c 2006-01-26 23:34:49.000000000 +0300 @@ -1,6 +1,6 @@ -/* $Id: exec.c,v 6.35 2005/11/07 10:47:25 cher Exp $ */ +/* $Id: exec.c,v 6.36 2006/01/26 20:34:49 cher Exp $ */ -/* Copyright (C) 1998-2005 Alexander Chernov */ +/* Copyright (C) 1998-2006 Alexander Chernov */ /* Created: <1998-01-21 14:33:28 cher> */ /* @@ -137,6 +137,8 @@ static int verbose_flag; /* 1 - r #ifdef __linux__ static int linux_fix_time_flag = -1; static int linux_ms_time_limit = -1; +static int linux_ptrace_code = -1; +static int linux_rlimit_code = -1; static void linux_set_fix_flag(void); #endif @@ -875,6 +877,15 @@ task_EnableMemoryLimitError(tTask *tsk) { task_init_module(); ASSERT(tsk); + +#ifdef __linux__ + if (linux_fix_time_flag < 0) linux_set_fix_flag(); + ASSERT(linux_ms_time_limit >= 0); + ASSERT(linux_fix_time_flag >= 0); +#endif /* __linux__ */ + + if (linux_ptrace_code <= 0) return -1; + tsk->enable_memory_limit_error = 1; return 0; } @@ -1243,8 +1254,8 @@ task_Start(tTask *tsk) int tfd; int code; - if (tsk->enable_memory_limit_error) { - code = ptrace(0x20, 0, 0, 0); + if (tsk->enable_memory_limit_error && linux_ptrace_code > 0) { + code = ptrace(linux_ptrace_code, 0, 0, 0); //fprintf(stderr, "reuse: ptrace returned %d\n", code); } @@ -1426,7 +1437,7 @@ task_Start(tTask *tsk) memset(&lim, 0, sizeof(lim)); lim.rlim_cur = tsk->max_time_millis; lim.rlim_max = tsk->max_time_millis; - if (setrlimit(11, &lim) < 0) { + if (setrlimit(linux_rlimit_code, &lim) < 0) { code = MAKECODE(TASK_ERR_LIMIT_CPU_FAILED, errno); write(comm_fd + 1, &code, sizeof(code)); _exit(TASK_ERR_LIMIT_CPU_FAILED); @@ -1776,65 +1787,80 @@ linux_set_fix_flag(void) if (linux_fix_time_flag >= 0) return; if (linux_ms_time_limit >= 0) return; - - // check for millisecond time limit - if ((pid = fork()) < 0) return; - if (!pid) { - struct rlimit lim; - - memset(&lim, 0, sizeof(lim)); - lim.rlim_cur = 1000; - lim.rlim_max = 1000; - if (setrlimit(11, &lim) < 0) _exit(1); - _exit(0); + + if (uname(&buf) < 0 || strcasecmp(buf.sysname, "linux") + || sscanf(buf.release, "%d.%d", &mjver, &mnver) != 2) { + linux_fix_time_flag = 0; + linux_ms_time_limit = 0; + return; } - if (wait4(pid, &status, 0, &usage) != pid) return; - linux_ms_time_limit = 0; - if (WIFEXITED(status) && WEXITSTATUS(status) == 0) - linux_ms_time_limit = 1; - - /* it looks like this check does not work on 2.6/x86_64 */ - if (uname(&buf) >= 0) { - // however `uname' may hardly fail... - if (!strcasecmp(buf.sysname, "linux") - && sscanf(buf.release, "%d.%d", &mjver, &mnver) == 2 - && (mjver >= 3 || (mjver == 2 && mnver >= 6))) { - linux_fix_time_flag = 0; - return; - } - } + if (mjver >= 3 || (mjver == 2 && mnver >= 6)) + linux_fix_time_flag = 0; - if ((pid = fork()) < 0) return; - if (!pid) { - struct rlimit lim; - - memset(&lim, 0, sizeof(lim)); - lim.rlim_cur = 0; - lim.rlim_max = 0; - if (setrlimit(RLIMIT_CPU, &lim) < 0) _exit(1); - - // FIXME: is it good to run busy loop for 1 second? - while (1); - _exit(1); + if (mjver == 2 && mnver == 4) { + linux_ptrace_code = 0x20; + linux_rlimit_code = 11; + } else if (mjver == 2 && mnver == 6) { + linux_ptrace_code = 0x4280; + linux_rlimit_code = 15; + } else { + // FIXME: yet unsupported version, don't even try } - retcode = wait4(pid, &status, 0, &usage); - // FIXME: we should not leave a process running... - if (retcode != pid) return; - - // if user time is > 0.5 sec consider that we should adjust limit time - if (usage.ru_utime.tv_sec >= 1 || usage.ru_utime.tv_usec >= 500000) { - linux_fix_time_flag = 1; + // check for millisecond time limit + if (linux_rlimit_code > 0) { + if ((pid = fork()) < 0) return; + if (!pid) { + struct rlimit lim; + + memset(&lim, 0, sizeof(lim)); + lim.rlim_cur = 1000; + lim.rlim_max = 1000; + if (setrlimit(linux_rlimit_code, &lim) < 0) _exit(1); + _exit(0); + } + + if (wait4(pid, &status, 0, &usage) != pid) return; + linux_ms_time_limit = 0; + if (WIFEXITED(status) && WEXITSTATUS(status) == 0) + linux_ms_time_limit = 1; } else { - linux_fix_time_flag = 0; + linux_ms_time_limit = 0; + } + + if (linux_fix_time_flag < 0) { + if ((pid = fork()) < 0) return; + if (!pid) { + struct rlimit lim; + + memset(&lim, 0, sizeof(lim)); + lim.rlim_cur = 0; + lim.rlim_max = 0; + if (setrlimit(RLIMIT_CPU, &lim) < 0) _exit(1); + + // FIXME: is it good to run busy loop for 1 second? + while (1); + _exit(1); + } + + retcode = wait4(pid, &status, 0, &usage); + // FIXME: we should not leave a process running... + if (retcode != pid) return; + + // if user time is > 0.5 sec consider that we should adjust limit time + if (usage.ru_utime.tv_sec >= 1 || usage.ru_utime.tv_usec >= 500000) { + linux_fix_time_flag = 1; + } else { + linux_fix_time_flag = 0; + } } } #endif #if REUSE_COMPILE_CVSID - 0 != 0 static char const cvsid[] = -"$Id: exec.c,v 6.35 2005/11/07 10:47:25 cher Exp $"; +"$Id: exec.c,v 6.36 2006/01/26 20:34:49 cher Exp $"; #endif /* REUSE_COMPILE_CVSID */ /* diff -ruNp reuse-4.2.2/source/win32/os_env.c reuse/source/win32/os_env.c --- reuse-4.2.2/source/win32/os_env.c 2004-09-11 10:13:24.000000000 +0400 +++ reuse/source/win32/os_env.c 2006-01-26 23:35:28.000000000 +0300 @@ -1,7 +1,7 @@ /* -*- mode:c -*- */ -/* $Id: os_env.c,v 1.4 2004/09/11 06:13:24 cher Exp $ */ +/* $Id: os_env.c,v 1.5 2006/01/26 20:35:28 cher Exp $ */ -/* Copyright (C) 2002-2004 Alexander Chernov */ +/* Copyright (C) 2002-2005 Alexander Chernov */ /* * This library is free software; you can redistribute it and/or @@ -119,12 +119,20 @@ os_GetFilename(char const *path) * RETURN: 0 - ok, <0 - error */ int -os_GuessProjectEnv(char const *path, char const *project) +os_GuessProjectEnv(char *path, char const *project) { -#if defined __REUSE__ char *p_config = 0; char *p_home = 0; + if (project) { + p_home = xstrmerge2(project, "_HOME"); + p_config = xstrmerge2(project, "_CONFIG"); + set_PRJ_HOME_name(p_home); + set_PRJ_CONFIG_name(p_config); + xfree(p_home); + xfree(p_config); + } + p_config = get_PRJ_CONFIG_name(); p_home = get_PRJ_HOME_name(); @@ -249,17 +257,14 @@ os_GuessProjectEnv(char const *path, cha return -1; } } -//fprintf(stderr, "%s=%s\n", p_home, getenv(p_home)); + //fprintf(stderr, "%s=%s\n", p_home, getenv(p_home)); return 0; -#else - return -1; -#endif /* __REUSE__ */ } #if REUSE_COMPILE_CVSID - 0 != 0 static char const rcsid [] = -"$Id: os_env.c,v 1.4 2004/09/11 06:13:24 cher Exp $"; +"$Id: os_env.c,v 1.5 2006/01/26 20:35:28 cher Exp $"; #endif /* REUSE_COMPILE_CVSID */ /*