[MLton-user] Unix.execute question

Matthew Fluet fluet@cs.cornell.edu
Fri, 14 Jan 2005 10:59:58 -0500 (EST)


> Isn't Unix.execute supposed to  exec an application in the environment
> of the calling process ?

Yes.

> I'm working on an application that launches another one for a subtask,
> using Unix.execute.   The executable of the subtask  is reachable from
> my Path,  but my application only  works if that executable  is put in
> the working  directory (otherwise it  fails with OS.SysErr  saying "No
> such file or directory").
>
> Am I misunderstanding the man page for Unix.execute ?

Yes.  Unix.execute requires that the cmd argument name the executable
exactly.  Although the execute-ed process inherits the environment of the
calling process, there is no requirement that Unix.execute consult that
environment when looking for the command.  To put it another way,

 Unix.execute (cmd, args) ==
   Posix.Process.exec (cmd, args)

but

 Unix.execute (cmd, args) <>
   Posix.Process.execp (cmd, args).

See
  http://www.standardml.org/Basis/posix-process.html
  http://www.standardml.org/Basis/unix.html