Menu

#141 setpgrp semantics still not working

closed-fixed
nobody
PTLib (142)
5
2009-06-02
2009-05-06
No

Building on OS X 10.4 using ptlib SVN from this past weekend, the autoconf test for whether setpgrp takes a void parameter (which mine does) is broken two ways. First, a bug in configure.ac causes a shell syntax error in configure.

P_SETPGRP_SYSTEMV=0
AC_MSG_CHECKING(if setpgrp takes no paramaters)
AC_TRY_COMPILE([#include <unistd.h>],
[pid_t p = setpgrp();], P_SETPGRP_NOPARM=1)
if test ${P_SETPGRP_NOPARM} = 1 ; then
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
AC_DEFINE_UNQUOTED(P_SETPGRP_NOPARM, ${P_SETPGRP_NOPARM})

the AC_TRY_COMPILE fails, so P_SETPGRP_NOPARM is left undefined. That makes a shell syntax error later when AC_DEFINE_UNQUOTED is converted into:

if test ${P_SETPGRP_NOPARM} = 1 ; then

because "test = 1" if the var is null. Need to make sure "null var" is still not "null string in test()". One easy way is to set _SETPGRP_NOPARM=0 before the AC_TRY_COMPILE or as the "if compile fails" argument to that macro, so the var will always be defined (as 0 or 1) by the time we get to AC_DEFINE_UNQUOTED

Second bug is in pmachdep.h, where the P_SETPGRP_NOPARM token is used to decide how to define the PSETPGRP macro:

#ifdef P_SETPGRP_NOPARM
#define PSETPGRP() setpgrp()
#else
#define PSETPGRP() setpgrp(0, 0)
#endif

Notice that the configure.ac AC_DEFINE_UNQUOTED is always run, and sets the P_SETPGRP_NOPARM to either 1 or blank (or 0, per my above correction), but it is tested with #ifdef. It's *always* defined. If configure.ac is going to "define as different values", pmachdep.h needs to test for "certain values". Otherwise, configure.ac needs to "only define sometimes" if pmachdep.h is going to test for "defined?".

So another adjustment for the configure.ac broken-ness is to put the AC_DEFINE_UNQUOTED inside the if() control, so it will only be defined at all vs not rather than defined to various values.

Discussion

  • Daniel Macks

    Daniel Macks - 2009-05-06

    Er, make that mine does *not* take void. OS X takes void (the normal POSIX form) as of 10.5, but 10.4 can take void or not (depending on some other -D tokens) and defaults to the two-parameter form.

     
  • Robert Jongbloed

    Should now be fixed in trunk, can you confirm?

     
  • Robert Jongbloed

    • status: open --> pending-fixed
     
  • SourceForge Robot

    This Tracker item was closed automatically by the system. It was
    previously set to a Pending status, and the original submitter
    did not respond within 14 days (the time period specified by
    the administrator of this Tracker).

     
  • SourceForge Robot

    • status: pending-fixed --> closed-fixed
     

Log in to post a comment.