unix package

Ian Lynagh igloo at earth.li
Thu Jun 28 10:08:48 EDT 2007


Hi all,

Currently the unix package is a mishmash of different solutions to the
portability problem. Here are all the ones I've found, along with what I
think the best action would be. If this sounds reasonable then I'll
start making patches and proposals as appropriate.

(for POSIX/SUS, see http://www.opengroup.org/onlinepubs/009695399/)

1) Values outside of the scope of the package, conditionally available:
   * System.Posix.Signals.Exts.*

Propose: Moving modules into a new package, unix-exts perhaps.

2) Things that fall back to probably-reasonable alternatives:
   * unsetEnv, setEnv
   * PATH_MAX

Propose: Leave as they are.

3) Things falling back to functionality which can cause problems:
   * The Haskell usleep uses the C usleep (marked Obsolescent) if
     nanosleep (a Timer extension) isn't available. C's usleep interacts
     badly with GHC's threaded RTS.

Propose: Leave as it is.

4) Things that raise errors at runtime if they are not available,
   but there is something we could fall back to:
   * getGroupEntryForID (getgrgid_r, thread-safe extension)
   * getGroupEntryForName (getgrnam_r, thread-safe extension)

Propose: Write fallback code.

5) Things that raise errors at runtime if they are not available,
   but as far as I can see are required to be available anyway:
   * _PC_* in System/Posix/Files.hsc
   * getUserEntryForID (getpwuid)
   * getUserEntryForName (getpwnam)
   * grBufSize (sysconf, _SC_GETGR_R_SIZE_MAX)
   * pwBufSize (sysconf, _SC_GETPW_R_SIZE_MAX)
   * sysconfWithDefault (sysconf)

Propose: Change to using them unconditionally and see if any platforms
         break.

6) Things depending on optional functionality, conditionally available:
   * setSymbolicLinkOwnerAndGroup depends on lchown, an XSI extension
     http://www.opengroup.org/onlinepubs/009695399/functions/lchown.html
   * RLIMIT_AS (ResourceTotalMemory), RLIM_SAVED_MAX, RLIM_SAVED_CUR
     (all of the rlimit stuff actually appears to be an XSI extension).

Propose: Move to unix-xsi package.

7) Things that raise errors at runtime if they are not available:
   * getAllGroupEntries (getgrent, XSI extension)
   * getAllUserEntries (getpwent, setpwent, endpwent, XSI extensions)
   * Various in DynamicLinker.Prim

Propose: Move to unix-xsi package.

(for both 6 and 7, an alternative would be to just make them
unconditionally used in the unix package; I'm not sure what platforms,
if any, this would break on).

8) Things that are implemented only for certain compilers:
   * forkProcess (GHC-only)

Propose: Write implementations for other compilers/interpreters.


Thanks
Ian



More information about the Libraries mailing list