mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
Fixes for command line arguments coming from /proc/$$/cmdline.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@9649 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
555c532732
commit
526a6985a6
7 changed files with 724 additions and 528 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,7 +1,19 @@
|
|||
2001-04-21 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* config/config.proccmd.c: New test for behavior of /proc cmdline
|
||||
* acconfig.h: New CMDLINE_TERMINATED constant
|
||||
* configure.in: Use test to set CMDLINE_TERMINATED
|
||||
* configure: regenerated
|
||||
* Headers/Foundation/config.h.in: regenerated
|
||||
* Source/NSProcessInfo.m : ([+load]) modified to use CMDLINE_TERMINATED
|
||||
to decide how to use /proc/$$/cmdline when determining process args.
|
||||
Should now work 100% on all linux versions I hope.
|
||||
|
||||
2001-04-20 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSData.m ([NSMutableDataMalloc
|
||||
-replaceBytesInRange:withBytes:]): Check length, not capacity!
|
||||
Conform to documentation, and avoid possibility of 'hole' in data.
|
||||
* Source/NSInvocation.m: _get_arg() indirection fix suggested by
|
||||
Michael Scheibler.
|
||||
|
||||
|
|
|
@ -27,6 +27,9 @@
|
|||
/* Define if you have the dladdr function. */
|
||||
#undef HAVE_DLADDR
|
||||
|
||||
/* Define if your system terminates the final argument in /proc/$$/cmdline */
|
||||
#undef CMDLINE_TERMINATED
|
||||
|
||||
/* Define if your system needs to have short/int word aligned */
|
||||
#undef NEED_WORD_ALIGNMENT
|
||||
|
||||
|
|
|
@ -268,7 +268,6 @@ static char **_gnu_noobjc_env;
|
|||
char *proc_file_name = NULL;
|
||||
FILE *ifp;
|
||||
int c;
|
||||
int last;
|
||||
int argument;
|
||||
int length;
|
||||
int position;
|
||||
|
@ -324,7 +323,6 @@ static char **_gnu_noobjc_env;
|
|||
ifp = fopen(proc_file_name, "r");
|
||||
if (ifp == NULL)
|
||||
goto proc_fs_error;
|
||||
last = 0;
|
||||
while (1)
|
||||
{
|
||||
c = getc(ifp);
|
||||
|
@ -332,11 +330,9 @@ static char **_gnu_noobjc_env;
|
|||
_gnu_noobjc_argc++;
|
||||
else if (c == EOF)
|
||||
break;
|
||||
last = c;
|
||||
}
|
||||
#ifndef __FreeBSD__
|
||||
if (last != 0)
|
||||
_gnu_noobjc_argc++;
|
||||
#if (CMDLINE_TERMINATED == 0)
|
||||
_gnu_noobjc_argc++;
|
||||
#endif
|
||||
/*
|
||||
* Now _gnu_noobcj_argc is the number of arguments;
|
||||
|
@ -366,9 +362,9 @@ static char **_gnu_noobjc_env;
|
|||
if (_gnu_noobjc_argv[argument] == NULL)
|
||||
goto malloc_error;
|
||||
argument++;
|
||||
if (argument == _gnu_noobjc_argc || c == EOF) // End of command line
|
||||
break;
|
||||
length = 0;
|
||||
if (c == EOF) // End of command line
|
||||
break;
|
||||
}
|
||||
}
|
||||
fclose(ifp);
|
||||
|
|
|
@ -12,6 +12,9 @@
|
|||
/* Define if you have the dladdr function. */
|
||||
#undef HAVE_DLADDR
|
||||
|
||||
/* Define if your system terminates the final argument in /proc/$$/cmdline */
|
||||
#undef CMDLINE_TERMINATED
|
||||
|
||||
/* Define if your system needs to have short/int word aligned */
|
||||
#undef NEED_WORD_ALIGNMENT
|
||||
|
||||
|
|
28
config/config.proccmd.c
Normal file
28
config/config.proccmd.c
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Check to see if the final cmdline arg recorded in the /proc filesystem
|
||||
* is terminated by a nul.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
int main()
|
||||
{
|
||||
char buf[32];
|
||||
FILE *fptr;
|
||||
int result = 1;
|
||||
int c;
|
||||
|
||||
sprintf(buf, "/proc/%d/cmdline", getpid());
|
||||
fptr = fopen(buf, "r");
|
||||
if (fptr != 0)
|
||||
{
|
||||
while ((c = fgetc(fptr)) != EOF)
|
||||
{
|
||||
result = c;
|
||||
}
|
||||
fclose(fptr);
|
||||
}
|
||||
if (result != 0)
|
||||
{
|
||||
result = 1;
|
||||
}
|
||||
return result;
|
||||
}
|
15
configure.in
15
configure.in
|
@ -651,6 +651,21 @@ fi
|
|||
AC_SYS_PROCFS
|
||||
AC_SYS_PROCFS_EXE_LINK
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Check if /proc/$$/cmdline terminates the last argument with a nul
|
||||
#--------------------------------------------------------------------
|
||||
AC_MSG_CHECKING(/proc/$$/cmdline terminated by nul)
|
||||
AC_TRY_RUN([#include "$srcdir/config/config.proccmd.c"],
|
||||
CMDLINE_TERMINATED=1,
|
||||
CMDLINE_TERMINATED=0,
|
||||
CMDLINE_TERMINATED=0)
|
||||
AC_DEFINE_UNQUOTED(CMDLINE_TERMINATED, $CMDLINE_TERMINATED)
|
||||
if test $CMDLINE_TERMINATED = 1; then
|
||||
AC_MSG_RESULT(yes)
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Check if short and int values need to be word aligned
|
||||
#--------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in a new issue