Age | Commit message (Collapse) | Author | Files | Lines |
|
This changes especially makes buffered I/O work
with non-blocking channels.
- separate read and write buffering
- support for timeout on blocking read
- read/write on same channel in event loop with buffering
- read buffer is the same across read, gets, copyto
- autoflush non-blocking writes via event loop
- copyto can now copy to any filehandle-like command
- add some copyto tests
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Not in source files
See https://ariadne.space/2021/12/21/stop-defining-feature-test-macros-in-your-code/
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Go through the Jim versions where it makes sense so we can add debugging
or other features as required.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
ifdef out some unix-only code so that we don't get
compiler complaints on Windows.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
On platforms where using vfork emits a warning, use fork instead
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Only on unix systems. Does waitpid(-1, ...) to wait for any child
process to exit.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
On win32, a process is identified by a HANDLE, but for identifying
a running process we should use GetProcessId() to return a meaningful integer.
This means we need to be able to back and forth between a pid and a process handle
(phandle). We also need to be careful to get the pid before the process handle closes
since it isn't available afterwards.
Also call the handle to intptr_t for open_osfhandle() to avoid a compiler warning.
Fixes #217
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Don't try to dup2() a file descriptor that is already
correct. This can happen if, for example, stdin is closed
and exec redirects stdin from a file, thus opening the input
as file descriptor 0.
Fixes #201
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
jim.h now includes JIM_ABI_VERSION that should be incremented whenever
the ABI changes. Then all loadable modules should call Jim_CheckAbiVersion()
to make sure they are loaded against the correct version.
Add Jim_PackageProvideCheck() that does both Jim_CheckAbiVersion()
and Jim_PackageProvide() to simplify the implementation of loadable extensions.
Also rename the "big" sqlite3 extension to just sqlite to avoid a naming conflict with
the smaller jim-sqlite3 extension.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
numPids is always zero here so the code does nothing
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
When executing "exec.test" under valgrind, it reports several
warning messages
Warning: invalid file descriptor -1 in syscall close()
Add proper check around close()
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
|
|
Previously SIGPIPE was set to SIG_DFL before vfork so that child processes
always had SIGPIPE enabled. This makes it impossible to disable SIGPIPE for
child processes. So don't do this. Instead allow the disposition of SIGPIPE
to be handled by the 'signal' command.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
The incorrect environment was used in 8f7471a0f
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Avoid modification of any variables on the parents stack.
Avoid use of stdio in the event that execve fails.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Now simply 'wait'
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
- fix popen [open "|pipeline ..."] to return meaningful status in close
(but note that stderr is not captured)
- popen pipelines can now be used as the target of exec redirection
- overally improvements to exec on windows. Now crt file descriptors
are used throughout
- add support for [pid], [wait] and popen on windows
- os.wait is now wait, and integrates with [exec ... &] to be able
to wait for running background tasks
- [socket pipe] is now also [pipe] and is supported on windows
- [file tempfile] is supported on windows
- move duplicated code between jim-aio.c and jim-exec.c to jimiocompat.c
- Fix [exec] on windows to match unix semantics wrt sharing the parent stream
unless redirected rather than using /dev/null
- On windows redirect to or from /dev/null is automatically converted to NUL:
- If signal support is disabled, implement a minimal Jim_SignalId() for exec and wait
- aio now supports getfd, to return the underlying file descriptor.
This is used by exec to support redirection, and allows popen channels
to support exec redirection.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
These are only allowed as separate args. One check was allowing
them as a prefix which could lead to an invalid memory access
Reported-by: Ryan Whitworth <me@ryanwhitworth.com>
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Reported-by: Ryan Whitworth <me@ryanwhitworth.com>
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Reported-by: Evan Hunter <evan@ozhiker.com>
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
pkgconfig for SDL causes _GNU_SOURCE to be defined on the commandline,
hence causing an error when these source files re-define it.
|
|
Keeps valgrind happy
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Reported-by: Evan Hunter <evan@ozhiker.com>
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
The credit goes to @msteveb for finding this difference between
[exec] in Tcl 8.6 and Jim.
|
|
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Also, fix build if JIM_OPTIMIZATION is disabled
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
|
|
It is necessary to read output from the pipe before waiting
for children to exit to avoid the output filling up and blocking.
The error results still needs to be read after the children have
exited, since it is read from a temp file, not a pipe.
Increase the length of the input to test exec-8.1 to catch
the problem.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Fix a race condition in [exec] where stdout and stderr are read
without waiting until all child processes have exited. This meant
that the following may capture no stderr output.
exec >@stdout command-with-stderr
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Consider the command pipeline:
exec a | b | c
Previously, if any of the subcommands terminated abnormally (with a signal),
the stdout of the pipeline would be lost.
Now the output consists of:
1. standard output from the last command in the pipeline
2. standard error from all commands in the pipeline
3. all abnormal error terminations, if any - but suppressed if any standard error output
In addition, $::errorCode previously always contained the termination status of the last
subcommand, even if it succeeded. Now it contains the termination status of the last
subcommand that failed, or "NONE" if all succeeded.
Additionally, the order of $::errorCode was previously wrong, with pid after the signal id
rather than vice versa.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
This applies to [exec] and [file tempfile]
Reported-by: Jakub Wilk
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Set umask so that temp files are created with
permissions 0600.
Courtesy of coverity.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Sweep through and clean up all (most) of the comments in the code.
While there, adjust some variable and function names to be more consistent,
and make a few small code changes - again, mostly for consistency.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Two versions of the "trim trailing space" function
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Otherwise there is no way to affect the environment for exec
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Tabs accidentally crept into source files in violaton of the style guide
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
e.g. exec prog <<$data
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
caused mayhem in stdio etc.
|
|
Signed-off-by: Steve Bennett <steveb@workware.net.au>
Reported-by: af123 <jimdevel@hummypkg.org.uk>
|
|
On cygwin, setting environ before execvp() doesn't work,
but execvpe() does exist and works, so use that in preference
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Passing a zero refcount object to Jim_AioFilename() is a bad idea.
If the implementation changes, the object may be freed twice.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Simplifies the process of building loadable extensions
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|