| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
| |
Now that we're calling memset to clear data for each process it's
no longer necessary to zero the process times by hand.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Remove the code which passed applet names to child processes using
environment variables. This only allowed ps to display names for
its ancestors.
Instead attempt to read applet names from the memory of unrelated
processes.
The Microsoft documentation alone wasn't enough to figure out how
to do this. Additional hints from:
https://stackoverflow.com/questions/4298331/exe-or-dll-image-base-address
https://stackoverflow.com/questions/14467229/get-base-address-of-process
|
|
|
|
|
|
|
|
|
|
|
| |
The exit status from _cwait wasn't being correctly returned. This
resulted, for example, in the exit status of xargs being incorrect.
Running this:
$ ls | xargs ls
in a directory containing filenames with spaces should cause 'ls' to
fail and 'xargs' to return an exit status of 123.
|
|
|
|
|
|
|
|
| |
In the recently-added code to pass applet names to child processes use
local arrays to build the environment variables rather that allocating
them every time.
mingw_spawn can call mingw_spawn_proc instead of mingw_spawn_1.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In standalone shell mode all busybox-w32 applets are displayed as
'busybox.exe' in a process listing.
I haven't found a satisfactory way to query a running instance of
busybox-w32 to determine which applet it's running. Handle a couple
of cases:
- the process running the process scan knows its own PID and knows
which applet it is;
- just before invoking applet_main set an environment variable whose
name contains the PID and whose value is the current applet name.
Children running a process scan will inherit their parent's environment
and can therefore match the parent's PID to its applet name.
|
|
|
|
|
|
|
|
|
| |
The original procps_scan function takes care to clear the status
information before handling each process. Do the same for the
WIN32 version.
This requires moving the snapshot handle to the part of the structure
that isn't cleared on each iteration.
|
|
|
|
|
|
|
|
|
| |
The names of the callbacks to kill processes with a given signal were
confusing because they referred to the implementation rather than
the intent.
Create the new function kill_SIGTERM_by_handle which is more efficient
when a handle to the process to be killed is already available.
|
|
|
|
|
|
|
|
| |
Reduce the size of the binary by about 32 bytes:
- use xzalloc to allocate static buffers so we don't have to
initialise them;
- avoid duplicated code in spawnveq.
|
|
|
|
|
|
|
| |
It appears that uninitialised static variables are placed in the
data section rather than bss, increasing the size of the binary.
Rewrite some code to reduce the amount of static data.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Consistent processing of file extensions, as described in the previous
commit, has been applied to the 'which' applet and the functions
find_executable and mingw_spawn_interpreter.
In spawnveq check that the file to be executed exists and is executable,
and ensure that it won't have any extensions added by spawnve.
It's intended that all files passed to spawnve should have their names
fully specified. If this isn't the case the tests here will cause errors
which will need to be fixed.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Move the code to detect shell scripts and binary executables from
mingw_access to a separate function, has_exec_format. Call this function
in do_lstat to decide whether to set the executable bits in the file mode.
This will slow down stat but has a couple of advantages:
- shell scripts are highlighted in ls output
- the test applet can use stat(2) to detect executable files
The new function is used to handle another corner case in spawnveq:
binary executables without the usual .exe extension are only run by
spawnve if the file name ends with '.'.
Two minor changes:
- file_is_win32_executable has been renamed add_win32_extension to
clarify what it does
- a call to file_is_executable has been removed from find_command
in ash as it resulted in unhelpful error messages.
|
|
|
|
|
|
|
|
| |
Support batch files with .bat and .cmd extensions, similar to
what's done for .exe and .com.
Check extensions in the same order as Windows' spawn function:
.com, .exe, .bat, .cmd.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When passing -1 as pid to the waitpid() function, it is supposed to wait
for *any* child to exit. That is a bit tough to emulate on Windows given
that waitpid() returns only one pid, and if multiple children have exited,
subsequent calls to waitpid() should produce all of their pids
subsequently. Oh, and we would have to figure out which processes were
spawned and remember that list. And then, it would still be possible for
the children to exit in the meantime and for *another* process using the
pid, as Windows reuses pids very, very quickly.
So let's punt and simply state that we do not support that
functionality.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
|
|
|
|
|
|
| |
According to the man page:
If sig is 0, then no signal is sent, but existence and permission
checks are still performed
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Extend the implementation of kill(2) so that:
- Sending the TERM signal asks the target process to exit. As on
Unix it may not comply.
- Sending the KILL signal forcibly terminates the target process.
- Using a negative pid treats the target process as a process
group leader and signals it and all of its descendants.
- Using a pid of zero treats the current process as a process
group leader and signals it and all of its descendants.
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
As Git for Windows' source code recently learned, let's also avoid using
TerminateProcess() in BusyBox-w32: it does not allow the killed
processes' atexit() handlers to run.
Instead, jump through a couple of hoops by injecting a remote thread
that executes the ExitProcess() function.
This allows the atexit() handlers to run, at which point the exit code
of the process can already be queried via GetExitCodeProcess(), and
appropriate action can be taken, such as killing child processes.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
|
|
|
|
|
|
|
|
| |
It may be necessary to run ps as administrator to get information
about processes belonging to other users.
The code to detect GetTickCount64 at run-time was imported from
Git for Windows.
|
| |
|
|
|
|
|
| |
Remove the check for argv being NULL in spawnveq. It shouldn't
ever succeed.
|
|
|
|
|
|
| |
The function find_executable is more generic than needed here: it
can search for all matches on PATH whereas we only want the first.
Implement find_first_executable to do that.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Simplify how scripts are detected by parse_interpreter. It now:
- uses strtok to parse the line buffer;
- returns any options as a single string, not an array of separate options;
- returns both the full path of the interpreter and its name.
When a script is detected the sequence is now:
- if the path to the interpreter refers to an executable run that;
- else look up the interpreter name as a applet (if so configured) and
run the applet found;
- else search for the interpreter name on PATH.
|
|
|
|
|
|
|
|
| |
Add a function (has_exe_suffix) to replace explicit code to check
if a filename ends with '.exe. or '.com'.
Also shrink code that checks for '.exe' or '.com' on PATH in shell's
find_command function.
|
|
|
|
|
|
|
|
|
|
| |
The function signatures were inherited from Git's source code, but are
inconsistent with the declarations in the POSIX standard.
This requires quite a few changes in quite a few callers, unfortunately.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
|
|
|
|
|
| |
When spawning a process the file should be executed directly if its
filename contains any path separator, not just if it's an absolute
path.
|
|
|
|
|
| |
Upstream BusyBox allows PREFER_APPLETS and SH_STANDALONE to be set
independently. Allow such configurations to work in busybox-w32.
|
|
|
|
|
|
|
| |
The original WIN32 code used the BUSYBOX_APPLET_NAME environment variable
to pass the applet name to the spawned process. This was based on the
(apparently) mistaken idea that WIN32 would replace argv[0] with the
path to the executable.
|
|
|
|
|
|
|
|
|
|
| |
Previously spawn was returning a process handle which was treated as a
pid in certain circumstances. This resulted in the following failing:
find . -type f | sed xargs -n 1 sed -n '1 p'
It should output the first line of each file but stopped after the
first.
|
|
|
|
|
|
|
|
| |
Make mingw_spawn_applet and mingw_spawn_1 static.
The return value from spawnve is an exit code in synchronous mode
and a process handle in asynchronous mode. Pass these upwards
without interpretation.
|
|
|
|
|
|
|
|
| |
Correctly handle the case where an argument needs to be quoted
and has a backslash as its last character.
The issue was detected by the test "sed a cmd ended by double backslash"
in the BusyBox test suite.
|
| |
|
|
|
|
|
| |
The third argument should be int. We only support positive pid
values.
|
| |
|
| |
|
|
|
|
| |
_cwait requires a process handle, not a pid.
|
|
|
|
|
|
|
| |
Conflicts:
debianutils/which.c
editors/vi.c
libbb/executable.c
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* We only need to quote an argument if it contains whitespace.
* There's no point in quoting ? or * because Windows still expands
them. Anyhow, if the command line comes from a BusyBox shell it will
usually have handled the globbing, so we should turn off Windows
globbing for any wildcard that has made it through the shell without
expansion. This means that BusyBox commands run from cmd.exe won't do
wildcard expansion, though.
* Backslashes only need to be doubled if they occur immediately before
double quotes.
* Double quotes need to be escaped with a backslash.
|
|
|
|
|
|
|
|
|
|
|
| |
There are two changes here. The first, in mingw_spawn_1, removes
a post-increment of argv which should have no effect. The second,
in mingw_spawn, should fix a reported problem with xargs:
https://github.com/pclouds/busybox-w32/issues/19
Basically, 'find . -type f | xargs md5sum' was failing to process the
first file.
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
| |
On Linux, procps_scan() relies on /proc, which is obviously
unavailable on Windows.
This implementation currently supports procps_status_t.{pid,comm} only.
|
| |
|
| |
|
|
|
|
|
|
| |
Most of this was extracted from commit
e56b799d6ad8afba4168fffa7218d44c041a72d2
in Git repository.
|