summaryrefslogtreecommitdiff
path: root/win32 (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* win32: tailor inet_pton.c for use in busybox-w32Ron Yorston2018-02-221-11/+8
|
* win32: import inet_pton.c from ISC BINDRon Yorston2018-02-221-231/+182
| | | | | | | | The copy of inet_pton.c imported from gnulib was licensed under GPL3 which is incompatible with the GPL2-only licence of BusyBox. Import an MPL2-licensed version of this file from ISC BIND git master as of this date.
* win32: import fsync(2) implementation from gnulibRon Yorston2018-02-212-0/+76
|
* win32: use built-in shell for popen, if possibleRon Yorston2018-02-181-2/+12
| | | | | | | | | | | | | | | popen uses the shell to run the command provided. If BusyBox has been configured appropriately use the built-in shell for this. - Currently the only user of popen in busybox-w32 is awk, which uses it when piping to or from commands. - If the command is available as an applet the shell will use it. If a different version of the program is required the command will need to specify the full path. - This change means that popen will work even if no shell is present on the path. - Since the binary may have been run as sh.exe or awk.exe it's necessary to use the magic --busybox option.
* win32: add dummy sys/select.h required for pollRon Yorston2018-02-141-0/+0
|
* win32: update poll implementation to match latest gnulib versionRon Yorston2018-02-131-209/+207
|
* win32: always use safe API calls to manipulate environmentRon Yorston2018-02-131-100/+26
| | | | | | | | | | | It turns out that with the new toolchain safe API calls work on all all platforms. Even the original code from commit fa147bd7e works on Windows XP when built with the new tools. - Remove the unsafe environment manipulation via the environ array - Microsoft's putenv takes a copy of its argument so the string can be freed - Rewrite some routines and add more error checking
* date: support '-' format flag to remove zero paddingRon Yorston2017-12-091-0/+5
| | | | | | | The strftime provided by the Microsoft C runtime uses '#' as the format string flag to remove zero padding; glibc uses '-'. Support the use of the '-' flag for improved compatibility.
* win32: define statvfs as statfsRon Yorston2017-11-032-1/+3
| | | | | | df now uses statvfs instead of statfs. Support this by pretending that statfs *is* statvfs. Not really true but good enough for the present purpose.
* mingw: clarify that waitpid(-1, ...) is not supportedJohannes Schindelin2017-10-011-1/+1
| | | | | | | | | | | | | | | | | 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>
* win32: allow kill to send signal number 0Ron Yorston2017-09-271-0/+15
| | | | | | | According to the man page: If sig is 0, then no signal is sent, but existence and permission checks are still performed
* win32: improvements to implementation of kill(2)Ron Yorston2017-09-271-87/+94
| | | | | | | | | | | | | | | | | 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>
* kill: use gentler method than TerminateProcess()Johannes Schindelin2017-09-271-1/+161
| | | | | | | | | | | | | | | 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>
* ps: add support for CPU and elapsed time columnsRon Yorston2017-09-013-2/+106
| | | | | | | | 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.
* ps: add parent process id as a supported columnRon Yorston2017-08-311-0/+1
|
* win32/poll: avoid assumption that pointers are equivalent to longsJohannes Schindelin2017-08-311-1/+1
| | | | | | | | | This is a companion patch to 4319368c6 (Use gnulib poll, importing the version from git, 2012-03-30) (Git's implementation of IsConsoleHandle() was adjusted in the meantime). Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Ron Yorston <rmy@pobox.com>
* win32: further minor code shrinkRon Yorston2017-08-301-17/+11
| | | | | Remove the check for argv being NULL in spawnveq. It shouldn't ever succeed.
* win32: add a function to find executable on PATHRon Yorston2017-08-301-34/+30
| | | | | | 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.
* win32: changes to treatment of scriptsRon Yorston2017-08-301-58/+36
| | | | | | | | | | | | | | | 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.
* win32: shrink code to detect .exe filesRon Yorston2017-08-302-22/+21
| | | | | | | | 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.
* mingw: accommodate for BusyBox' assumptions about isatty()Johannes Schindelin2017-08-241-0/+27
| | | | | | | | | | | | | | | On Windows, isatty(fd) determines whether the file descriptor refers to a character device. The thing is: even NUL or a printer is a character device. BusyBox thinks, however, that isatty() only returns non-zero for an interactive terminal. So let's shadow isatty() by a version that answers the question BusyBox wants to have answered. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Ron Yorston <rmy@pobox.com>
* win32: remove implementation of mempcpyRon Yorston2017-08-232-28/+0
| | | | | mingw-w64 has its own mempcpy. And even if it didn't upstream BusyBox has one too. So we definitely don't need our own.
* win32/strptime: fix for negative timezonesJohannes Schindelin2017-08-231-0/+2
| | | | | | | I bet this has been fixed in gnulib, too. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Ron Yorston <rmy@pobox.com>
* win32/select: ensure that the implementation matches the prototypeJohannes Schindelin2017-08-231-0/+1
| | | | | | | | The libbb.h header implicitly includes mingw.h, which has the declaration of that function. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Ron Yorston <rmy@pobox.com>
* win32/fnmatch: fix old-style function declarationJohannes Schindelin2017-08-231-1/+1
| | | | | | | | | | | | It would be more straight-forward to simply #include "libbb.h" which includes a #define getenv mingw_getenv, but that header also defines isprint() to a function that is nowhere to be found, leading to link problems. So let's go the easy route. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Ron Yorston <rmy@pobox.com>
* win32/fnmatch: avoid old-style function definitionsJohannes Schindelin2017-08-231-12/+4
| | | | | Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Ron Yorston <rmy@pobox.com>
* win32/strptime: avoid old-style declarationsJohannes Schindelin2017-08-231-19/+5
| | | | | | | | This was inherited from gnulib. While at it, get rid of the ugly (and unneeded) LOCALE constants. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Ron Yorston <rmy@pobox.com>
* win32/strptime: ensure that strptime()/localtime_r() are declaredJohannes Schindelin2017-08-231-0/+1
| | | | | | | | | | When `#include`ing libbb.h, it implicitly includes mingw.h (with a prototype for strptime()) and it also defines _POSIX_THREAD_SAFE_FUNCTIONS so that the time.h header declares localtime_r(). Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Ron Yorston <rmy@pobox.com>
* win32/select: work around a compiler warningJohannes Schindelin2017-08-231-1/+1
| | | | | | | | | | | The `tend` variable is only ever initialized and used if the timeout is *not* infinite. However, GCC is not smart enough to figure that out. So just initialize the variable to 0 and be done with it already. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Ron Yorston <rmy@pobox.com>
* win32/mingw: fix signatures of the *execv*() family of functionsJohannes Schindelin2017-08-232-21/+19
| | | | | | | | | | 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>
* win32: remove unused functionsRon Yorston2017-08-231-21/+0
| | | | | The functions copy_environ and free_environ became unused following commit ac181bf54 "win32: simplify spawning applets".
* win32: rewrite implementation of system(3)Ron Yorston2017-07-311-66/+11
| | | | Rewrite mingw_system using mingw_spawn_proc. Also fix return values.
* win32: check for relative path when spawning processRon Yorston2017-07-311-1/+1
| | | | | | 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.
* win32: add dummy sys/prctl.hRon Yorston2017-07-291-0/+0
|
* Allow PREFER_APPLETS and SH_STANDALONE to be set separatelyRon Yorston2017-07-271-6/+12
| | | | | Upstream BusyBox allows PREFER_APPLETS and SH_STANDALONE to be set independently. Allow such configurations to work in busybox-w32.
* win32: simplify spawning appletsRon Yorston2017-07-211-24/+4
| | | | | | | 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.
* win32/regex: fix compile warningsJohannes Schindelin2017-07-144-13/+15
| | | | | | | | | | | | | | | | | | There are plenty of warnings that were not detected in Git's source code, due to some warnings being turned off in Git's build by default (even with DEVELOPER=1). The warnings fall into three categories: - constants being tested via `#if <name>` instead of `#ifdef <name>` - unused function parameters - one instance of an unnecessarily-shadowing variable This patch fixes all of them. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
* win32/regex: update to newest version in GitJohannes Schindelin2017-07-146-5109/+11169
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In 909696f13 (win32: Import regex source, 2010-04-14), Git's compat/regex/ was imported wholesale, with one change (to avoid redefining _GNU_SOURCE). For the record, the git.git commit mentioned in that commit message refers to a transient commit made to git.git's `next` branch which is rewound with every major Git version, therefore it is long gone. Also for the record, the correct reference would be: 3632cfc2487 (Use compatibility regex library for OSX/Darwin, 2008-09-07), i.e. the compat/regex/ source code as of Git v1.6.0.2. This commit updates the regex source code to that of Git v2.13.2, or bd8f0055836 (regex: fix a SIZE_MAX macro redefinition warning, 2016-06-07) in git.git. Instead of the original fixup to avoid redefining _GNU_SOURCE, we now require these changes relative to Git's source code: > diff --git a/win32/regex.c b/win32/regex.c > index 5cb23e5d5..95e5d757a 100644 > --- a/win32/regex.c > +++ b/win32/regex.c > @@ -18,9 +18,11 @@ > Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA > 02110-1301 USA. */ > > -#ifdef HAVE_CONFIG_H > -#include "config.h" > -#endif > +#define HAVE_LIBINTL_H 0 > +#define ENABLE_NLS 0 > +#define HAVE_ALLOCA 0 > +#define NO_MBSUPPORT 1 > +#define GAWK 1 > > /* Make sure no one compiles this code with a C++ compiler. */ > #ifdef __cplusplus Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
* Provide vfprintf replacementRon Yorston2017-02-071-0/+1
| | | | | vfprintf is used in ash_vmsg. It should be passed through the codepage conversion in winansi.c.
* win32: implement nanosleep and enable float sleep by defaultRon Yorston2017-01-181-0/+18
| | | | Don't expect sleeping for fractions of a second to be very accurate.
* win32: allow ANSI emulation to be disabledRon Yorston2016-11-101-2/+15
| | | | | If the environment variable BB_SKIP_ANSI_EMULATION is set (the value doesn't matter) escape sequences are passed through to the terminal.
* win32: don't attempt ANSI emulation on data containing NUL charactersRon Yorston2016-08-161-4/+11
|
* win32: allow for vsnprintf returning -1Ron Yorston2016-07-081-1/+6
| | | | | | | vsnprintf can return -1. I've seen it do this when writing to a small buffer while vsnprintf(NULL, 0, ...) returns a valid length. I'd prefer not to rely on the latter working with arbitrary old Windows runtimes so just skip ANSI emulation if -1 is returned.
* win32: correct cast of argument to _open_osfhandleRon Yorston2016-05-252-6/+6
|
* win32: return an error when lseek is applied to a pipeRon Yorston2016-05-241-0/+14
| | | | | | | | | | | tail failed to process input from a pipe correctly: $ echo -n 54321 | tail -c 3 543 It was trying to use lseek as an optimisation but WIN32 lseek doesn't return an error whan applied to a pipe. Fix this by providing a wrapper for lseek.
* ash: fix use of pid/handle in waitpid_childRon Yorston2016-05-181-1/+13
| | | | | | | | | | 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.
* win32: adjustments to spawn functionsRon Yorston2016-05-181-10/+10
| | | | | | | | 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.
* winansi: revert to previous console behaviour for vi/lessRon Yorston2016-04-261-0/+18
| | | | | | | | | | | | Recent changes to make the Windows console behave more like a *nix terminal didn't work too well for vi/less. On *nix the terminal buffer can't be scrolled while such screen-based applications are running. In the Windows console this remained possible and led to confusion. Add a new routine to allow vi/less to revert to their previous behaviour where the cursor is positioned at the top of the buffer and the entire buffer is cleared.
* lineedit: move console viewport to cursor on keypressRon Yorston2016-04-261-1/+1
| | | | | | When a normal *nix terminal has been scrolled back through its buffer, any keypress will return to the cursor position. Add code to lineedit.c to do the same for the Windows console.
* winansi: speed up clearing of screenRon Yorston2016-04-261-15/+10
| | | | | | | | | | | | | | | Various tasks on the shell command line (e.g. backspace, DEL, reverse search) were found to be slow when the console screen buffer was very large. This was because the entire buffer was being cleared in erase_till_end_of_screen(). Rewrite erase_till_end_of_screen() to only clear to the end of the visible screen and to be tidier. (Based on a suggestion by GitHub user avih.) Also, modify move_cursor to use coordinates relative to the current display (as ANSI escapes expect) rather than relative to the screen buffer.