Print this page
make: unifdef for other OSes (undefined)
@@ -55,20 +55,11 @@
#include <sys/stat.h> /* open() */
#include <sys/wait.h> /* wait() */
#include <ulimit.h> /* ulimit() */
#include <unistd.h> /* close(), dup2() */
-#if defined (HP_UX) || defined (linux)
-# include <sys/param.h>
-# include <wctype.h>
-# include <wchar.h>
-#endif
-#if defined (linux)
-# define wslen(x) wcslen(x)
-# define wscpy(x,y) wcscpy(x,y)
-#endif
/*
* Defined macros
*/
#if defined(DISTRIBUTED) || defined(MAKETOOL) /* tolik */
@@ -99,23 +90,11 @@
* The second attempt seems to work.
*/
int
my_open(const char *path, int oflag, mode_t mode) {
int res = open(path, oflag, mode);
-#ifdef linux
-// Workaround for NFS problem: even when all directories in 'path'
-// exist, 'open' (file creation) fails with ENOENT.
- int nattempt = 0;
- while (res < 0 && (errno == ESTALE || errno == EAGAIN || errno == ENOENT)) {
- nattempt++;
- if(nattempt > 30) {
- break;
- }
- sleep(1);
-#else
if (res < 0 && (errno == ESTALE || errno == EAGAIN)) {
-#endif
/* Stale NFS file handle. Try again */
res = open(path, oflag, mode);
}
return res;
}
@@ -130,21 +109,13 @@
redirect_io(char *stdout_file, char *stderr_file)
{
long descriptor_limit;
int i;
-#if defined (HP_UX) || defined (linux)
- /*
- * HP-UX does not support the UL_GDESLIM command for ulimit().
- * NOFILE == max num open files per process (from <sys/param.h>)
- */
- descriptor_limit = NOFILE;
-#else
if ((descriptor_limit = ulimit(UL_GDESLIM)) < 0) {
fatal_mksh(catgets(libmksdmsi18n_catd, 1, 89, "ulimit() failed: %s"), errmsg(errno));
}
-#endif
for (i = 3; i < descriptor_limit; i++) {
(void) close(i);
}
if ((i = my_open(stdout_file,
O_WRONLY | O_CREAT | O_TRUNC | O_DSYNC,
@@ -342,37 +313,20 @@
argv[argv_index++] = (char *)NOCATGETS("nice");
(void) sprintf(nice_prio_buf, NOCATGETS("-%d"), nice_prio);
argv[argv_index++] = strdup(nice_prio_buf);
}
argv[argv_index++] = shellname;
-#if defined(linux)
- if(0 == strcmp(shell->string_mb, (char*)NOCATGETS("/bin/sh"))) {
- argv[argv_index++] = (char*)(ignore_error ? NOCATGETS("-c") : NOCATGETS("-ce"));
- } else {
- argv[argv_index++] = (char*)NOCATGETS("-c");
- }
-#else
argv[argv_index++] = (char*)(ignore_error ? NOCATGETS("-c") : NOCATGETS("-ce"));
-#endif
if ((length = wslen(command)) >= MAXPATHLEN) {
tmp_mbs_buffer = getmem((length * MB_LEN_MAX) + 1);
(void) wcstombs(tmp_mbs_buffer, command, (length * MB_LEN_MAX) + 1);
cmd_argv_index = argv_index;
argv[argv_index++] = strdup(tmp_mbs_buffer);
retmem_mb(tmp_mbs_buffer);
} else {
WCSTOMBS(mbs_buffer, command);
cmd_argv_index = argv_index;
-#if defined(linux)
- int mbl = strlen(mbs_buffer);
- if(mbl > 2) {
- if(mbs_buffer[mbl-1] == '\n' && mbs_buffer[mbl-2] == '\\') {
- mbs_buffer[mbl] = '\n';
- mbs_buffer[mbl+1] = 0;
- }
- }
-#endif
argv[argv_index++] = strdup(mbs_buffer);
}
argv[argv_index] = NULL;
(void) fflush(stdout);
if ((childPid = fork()) == 0) {