Calvin Rose
60078e7950
Change os/execute implementation for windows.
2021-02-14 11:04:59 -06:00
Calvin Rose
49dcc816ae
Update os/shell to be non-blocking as well.
2021-01-18 16:44:22 -06:00
Calvin Rose
634219da2c
Fix windows swallowing IOCP events in many cases.
...
This fixes windows hanging on "failed" IO operations.
2021-01-17 20:41:59 -06:00
Calvin Rose
462e74ef87
Add os/proc-close to close all pipes associated with a subprocess.
...
This will not leak handles until the GC runs in most use cases.
2021-01-16 15:11:07 -06:00
Calvin Rose
c79480342b
Remove unused defines.
2021-01-16 07:19:28 -06:00
Calvin Rose
a1cc5ca045
Fix #593 .
...
Also add ev/give-supervisor to the core.
2021-01-16 07:18:07 -06:00
sogaiu
122e2a9378
Tweak os docs
2021-01-14 08:44:56 +09:00
Calvin Rose
61cca10cf6
Allow iterating through the properties of core abstract types.
2021-01-11 23:14:07 -06:00
Calvin Rose
bf01bf631d
More work on windows networking code.
...
Remove use of WSARecv and WSASend since for whatever reason
they seem suspect. We may want to revisit this later.
2021-01-11 18:00:31 -06:00
Calvin Rose
f0dbc2e404
Fix subprocess spawning on windows.
...
Also fix (:read stream :all)
2021-01-11 11:10:23 -06:00
Calvin Rose
4df1ac5b23
Fix some issues in os.c to diagnose improve windows subprocess code.
2021-01-11 09:06:39 -06:00
Calvin Rose
7b030fe70d
Fix some return issues.
2021-01-03 11:54:31 -06:00
Calvin Rose
9760cf1f4e
Fix MSVC warning.
2021-01-03 11:47:29 -06:00
Calvin Rose
47bb7fd21b
Begin implementing async subproccesses for windows.
2021-01-03 11:21:44 -06:00
Calvin Rose
1c7ed8ca48
Use PostQueuedCompletionStatus for threaded calls on windows.
...
Ore efficient than using a self pipe.
2021-01-03 11:08:12 -06:00
Calvin Rose
05166b3673
Fix proc getter bug.
2020-12-31 16:23:20 -06:00
Calvin Rose
0a1c93b869
Add ev api for making threaded calls.
...
Easy way to make arbitrary functions in C async.
2020-12-31 16:12:42 -06:00
Calvin Rose
788f91a36f
Remove unneeded book keeping for sub processes.
...
Since we are not using signals we no longer need some bookkeeping.
2020-12-31 11:52:12 -06:00
Calvin Rose
c831ecf5d2
Working implementation of process waiting with threads.
...
Does not require all sorts of signal handling code
that is not thread-safe and can "steal processes".
However, there is a much simpler way to add this functionality
by creating a new stream and thread for each subprocess when it is
waited on. This is perhaps _slightly_ less efficient but oh so much
simpler, since we can reuse all of our concepts from streams and there
is no need to implement a whole system around the selfpipe.
2020-12-31 11:22:18 -06:00
Calvin Rose
9e42ee153c
Merge branch 'master' into HEAD
2020-12-30 12:19:13 -06:00
Calvin Rose
d7954be5e5
Update docstring for os/open.
2020-12-28 11:00:15 -06:00
Calvin Rose
d53007739e
Invert read/write bits on pipe in os/execute.
...
It was backwards, breaking this functionality.
2020-12-09 19:04:05 -06:00
Calvin Rose
cbdea8f331
Make os/execute cooperate with ev module.
...
os/execute, os/proc-wait do not block (currently posix only).
This uses the self-pipe trick to turn signals into a pollable entity.
2020-11-29 15:36:21 -06:00
Calvin Rose
53aa19a916
Several changes to move pipe creation back into ev.c
2020-11-18 10:53:36 -06:00
Calvin Rose
1b6272db2e
Fix windows ifdef.
2020-11-15 19:55:58 -06:00
Calvin Rose
6e6900fa3a
os/execute and os/spawn can take streams.
2020-11-15 12:17:29 -06:00
Calvin Rose
a7ed3dea4b
Remove some flags in os/open.
2020-11-15 10:06:20 -06:00
Calvin Rose
cdcb774dc8
Add os/pipe and os/open.
...
ev/pipe -> os/pipe, and os/open is a wrapper
around the open system call.
2020-11-15 09:57:29 -06:00
Calvin Rose
540425a41b
Make docstring less confusing - Fix #493 .
2020-11-02 09:09:22 -06:00
Calvin Rose
32bf70571a
Fix os/spawn piping on windows and free handles on errors.
2020-09-13 20:49:38 -05:00
Calvin Rose
524c9b50d4
Add windows implementation for piping.
2020-09-12 19:56:48 -05:00
Calvin Rose
d3147b661b
Add :pipe to os/spawn for piping to subprocess.
...
Similar to Python's subprocess.PIPE, this creates and manages pipes
automatically for the caller.
2020-09-12 19:48:12 -05:00
Calvin Rose
b53890ddae
Make some changes for WASM build.
2020-09-07 16:08:43 -05:00
Calvin Rose
821a8dca3b
Fix os/spawn - os/execute switch.
2020-09-04 14:54:58 -05:00
Calvin Rose
0145b133a1
Add os/spawn instead of os/execute with :a
2020-09-04 08:09:05 -05:00
Calvin Rose
b0b137d7f0
Apply formatting to windows changes.
2020-09-02 19:12:27 -05:00
Calvin Rose
b0c09153c2
Allow IO redirection on windows.
2020-09-02 19:07:45 -05:00
Calvin Rose
0485078c6c
Fix some issues on BSD and Windows.
2020-09-01 21:47:08 -05:00
Calvin Rose
7079cc43c9
Make some improvements and add os/proc-kill as well.
2020-09-01 21:36:49 -05:00
Calvin Rose
e7fca0051e
Add :a option to os/execute, and allow redirecting stdio.
...
This should help cover a number of common cases for
use of subprocesses. This should also eventually work well
with the ev branch via
2020-09-01 20:06:35 -05:00
Calvin Rose
8b9ad2dce8
Add :x flag to os/execute.
2020-08-29 10:27:32 -05:00
Andrew Chambers
4d4ca7bb36
Initialize PRF with random data when it is enabled.
2020-08-04 12:13:36 +12:00
Calvin Rose
b89f0fac7b
Move clock shims to util (Helps #430 ).
...
The thread module should also use these clock shims rather
than clock_gettime, which is not available on older mac systems.
2020-07-03 09:54:58 -05:00
Jason Pepas
f06e9ae30c
Switch to using /dev/urandom for OS X prior to 10.7
2020-06-30 04:18:08 -05:00
Jason Pepas
f5d208d5d6
eliminate large stack allocation from arc4random_buf bodge
2020-06-30 04:06:20 -05:00
Jason Pepas
597d84e263
Add support for systems missing arc4random_buf
2020-06-29 21:06:13 -05:00
Jason Pepas
51bf8a3538
Add ppc to os/arch
2020-06-26 04:11:21 -05:00
Calvin Rose
106437bd45
Fixes #423
...
Re-add ifdef for realpath config option.
2020-06-14 15:50:09 -05:00
Leaf
75bc69ba2f
Implement os/realpath on Window with _fullpath
...
This is similar to realpath but differs in that realpath will complain
if the path does not exist. We could add our own exists check if we
really wanted to match that behaviour.
2020-06-02 09:05:41 +00:00
Calvin Rose
b72845609f
Add JANET_GIT to jpm.
...
This should allow work arounds for some windows installs.
Also, be clever about finding the location of te current git
executable on windows to avoid some path issues that seem to
occur on some windows installations.
2020-05-19 18:36:58 -04:00
Calvin Rose
3100080a50
Add NO_UMASK and NO_REALPATH config options.
2020-05-10 23:07:54 -05:00
Calvin Rose
235605bfa4
1.9.0 Release.
...
Fix up some documentation as well.
2020-05-10 16:45:33 -05:00
Calvin Rose
b1f76139a7
Add several configurable options - #379
2020-05-09 12:00:01 -05:00
Calvin Rose
bdd64f5656
Merge branch 'master' of github.com:janet-lang/janet
2020-05-06 18:52:57 -05:00
Calvin Rose
dc3e9fb77c
Add CLOEXECs when getting file descriptors ( #374 )
...
This should help address leaking file descriptors in multithreaded
programs. There are a few cases where a race can occur though, as
some apis (fopen and mktemp).
2020-05-06 18:33:25 -05:00
Andrew Chambers
a0f351c9fa
Fix (mostly nonsensible) race condition in multi threaded processes using os/execute with os/setenv.
2020-05-05 16:03:13 +12:00
Calvin Rose
8a89e50c13
:octal-permissions -> :int-permissions ( #347 )
2020-04-16 19:05:00 -05:00
Calvin Rose
5b82b9e101
Address compiler warning on macos.
2020-04-04 13:34:16 -05:00
Calvin Rose
8275da63fb
Address #331 - Add :octal-permissions
2020-04-03 18:29:45 -05:00
Calvin Rose
1aeb317863
Revise, revise, revise, and proofread.
2020-04-03 17:04:05 -05:00
Calvin Rose
b49b510732
Update os/link docstring.
2020-04-03 16:58:45 -05:00
Calvin Rose
a0d61e45d5
Change os/perm-str to os/perm-string.
2020-04-03 15:23:29 -05:00
Calvin Rose
95f1ef7561
Add umask support for windows, and allow parsing mode strings.
2020-04-03 15:14:11 -05:00
Calvin Rose
edb2fab64c
Merge branch 'master' of github.com:janet-lang/janet
2020-04-03 15:04:39 -05:00
Calvin Rose
464fb73d83
Add os/perm-int and os/perm-str.
...
This helps address #331 . While we could also
make os/stat return an integer, we don't do that yet
for api breakage reasons.
This also lets us use this logic on other functions
that take permission strings.
2020-04-03 15:02:12 -05:00
Andrew Chambers
3c2b1baff2
Add os/umask.
2020-04-02 23:33:50 +13:00
Calvin Rose
789ef3608b
Make format.
2020-04-01 08:54:01 -05:00
Calvin Rose
655633ef34
Tweak docstring.
2020-03-25 18:00:15 -05:00
Calvin Rose
3d1de237f6
Several changes to the os module.
...
- Add os/symlink
- Add os/realpath
2020-03-24 19:47:21 -05:00
Calvin Rose
6a63b13d69
Fix os/link docstring - Address #323
2020-03-21 16:18:58 -05:00
Calvin Rose
3aca5502dc
Allow :dst to be nil to set tm_isdst to be -1.
2020-03-18 22:23:27 -05:00
Calvin Rose
665f4bf248
Remove windows MSVC warnings about _stat.
2020-03-18 21:37:55 -05:00
Calvin Rose
b76ff3bdfc
Fix omission of daylight savings time in mktime
...
Since with daylight savings times, certain times
are ambiguous (the hours before and after the switch), mktime
needs to allow reading a dst flag.
2020-03-18 21:23:35 -05:00
Calvin Rose
00450cd9db
try and remove warnings on windows, format os.c.
2020-03-18 21:15:50 -05:00
Calvin Rose
c344a543b0
Merge pull request #318 from leahneukirchen/mktime
...
os/date fixes and os/mktime
2020-03-18 20:59:08 -05:00
Calvin Rose
eee8338064
Merge pull request #319 from leahneukirchen/lstat
...
os/lstat and os/readlink
2020-03-18 17:58:32 -05:00
Calvin Rose
3b5183a74e
Fixes #316 : os/execute should return non-zero on signals
...
Behave more like shells, and catch segfaults.
2020-03-18 17:49:20 -05:00
Leah Neukirchen
3ee43c3abb
add os/mktime, an inverse to os/date.
2020-03-18 23:45:02 +01:00
Leah Neukirchen
efdb13f0c7
os/date: allow negative timestamps.
...
Why not? Even on 32-bit time_t systems this lasts until late 1901.
2020-03-18 23:45:02 +01:00
Leah Neukirchen
f013c6e48d
os/date: check the second argument truthy, not the third.
2020-03-18 23:45:02 +01:00
Leah Neukirchen
6e67899401
Add os/readlink.
2020-03-18 20:05:48 +01:00
Leah Neukirchen
381dd1ce98
Add os/lstat.
2020-03-18 20:05:48 +01:00
Calvin Rose
4a05b4556e
Fix MSVC build warning.
2020-03-14 12:02:31 -05:00
Calvin Rose
c074615550
Revert to 9 char permission strings on windows.
2020-03-14 12:00:11 -05:00
Calvin Rose
bac2b74b3d
Add os/chmod.
2020-03-14 11:57:04 -05:00
Calvin Rose
0600b32908
Fix docstring for os/cd - Fixes #307
2020-03-13 15:01:48 -05:00
Calvin Rose
a68ee7aac6
Update Copyright 2020.
2020-01-12 10:50:37 -06:00
Calvin Rose
b54d9725d8
Fix MSVC errors.
2020-01-12 10:18:03 -06:00
Calvin Rose
3d40c95e80
Add ability to Janet signal from C functions.
...
While C functions are not re-entrant, signaling from a C function
can be used to implement async returns. When resuming a fiber that
signalled from within a C function, the fiber is started after the
instruction that emitted the signal. The resume argument is used
as the return result from the c function.
2020-01-10 20:44:16 -06:00
Calvin Rose
ed5027db5d
Address #242
...
Synchronize critical sections in setenv/getenv/environ.
2020-01-06 22:41:18 -06:00
Andrew Chambers
ec1a06cfaf
Optional default value for os/getenv.
2020-01-07 11:21:05 +13:00
Calvin Rose
6c7f376410
Try to remove potential overflow bugs.
...
Also make integer to size_t casts explicit rather than relying on
int32_t * sizeof(x) = size_t. This is kind of a personal preference for
this problem.
2020-01-02 22:08:17 -06:00
Calvin Rose
9dd152dc28
Add features.h for feature test macros.
...
Because we use an amalgated build, feature
test macros should be set in a single file that
is included before any other headers, and is placed
at the top of the amalgamated build.
2019-12-30 19:06:15 -05:00
Calvin Rose
3492ed6d88
Windows installer pulls version from interpreter.
...
This should make version updates simpler. Also
try an make installer write to ProgramFiles instead
of ProgramFiles (x86) for 64 bit build.
2019-12-19 13:18:46 -05:00
Calvin Rose
2b2c1ff917
Get rid of warning on BSDs.
2019-12-15 16:04:43 -06:00
Calvin Rose
c7912249b2
Typo in #ifdef.
2019-12-15 15:56:26 -06:00
Calvin Rose
b8004555ea
Start cleaning up defines in janet.h
2019-12-15 15:41:58 -06:00
Calvin Rose
58ff7f0788
BSD os.c fix with arc4random.
2019-12-15 12:47:12 -06:00
Calvin Rose
f1afc5b0b4
Address #214
...
This adds several common patterns, which are defined in
boot.janet. This essentially gives more primitive patterns
to work with out of the box.
Fix build when JANET_REDUCED_OS is defined.
2019-12-14 20:39:14 -06:00
Calvin Rose
36b2f27873
Merge branch 'master' into threads-3
2019-12-12 17:07:03 -06:00
Calvin Rose
b8e02afd1a
Improve error messages in os.c and jpm
...
In os/* functions, show failed path name. In jpm, indicate
a permission issue if we can't stat the file.
2019-12-12 03:20:20 -06:00
Calvin Rose
38f7e256d0
Port threads code to Windows API
...
Can run demo in examples/threads.janet
2019-12-10 20:32:41 -05:00
Calvin Rose
600bed9f6d
Merge pull request #209 from andrewchambers/cryptorand2
...
Add os/cryptorand.
2019-12-03 19:12:32 -06:00
Andrew Chambers
0ac5b243c7
Add os/cryptorand.
2019-12-04 14:02:37 +13:00
Calvin Rose
ac85fca8a1
Fix warnings for appveyor.
2019-12-02 09:07:49 -06:00
Calvin Rose
4e4cdb6356
Run formatter.
2019-11-28 23:26:11 -05:00
Andrew Chambers
07db4c530e
Add os/environ.
2019-11-28 19:00:52 +13:00
Calvin Rose
719f7ba0c4
Default to UTC for date.
2019-11-09 16:57:21 -06:00
Calvin Rose
a18a251d16
Address some issues found in lgtm
...
Caught a few potentially issues with overflows, as well as use of
unsafe function localtime.
2019-10-10 22:59:43 -05:00
Calvin Rose
7bee204390
Fix installer.
2019-09-22 13:29:34 -04:00
Calvin Rose
81789a6930
Add wasm to architectures returned by os/arch.
2019-08-18 10:08:52 -05:00
Calvin Rose
28fb2403d9
Add os/arch to core.
...
Also allow setting custom keywords for compiled
os name and architecture name.
2019-08-18 10:00:04 -05:00
Calvin Rose
d6a1faa380
Typos.
2019-07-27 11:36:48 -05:00
Calvin Rose
3c133bd677
Add more values for (os/which)
...
Some bsd flavors.
2019-07-27 11:29:40 -05:00
Calvin Rose
dfe00fee94
Building standalone binaries on linux working.
...
Mostly changes to cook and jpm. Also some
code for file associations in the windows installer, and
adding the :linux value from os/which (instead of just :posix).
2019-07-26 22:43:54 -05:00
Calvin Rose
5689ef1af1
Add keyword flag utility for modules.
2019-06-12 12:05:48 -04:00
Calvin Rose
d9a4ef05ac
Update docstring format.
...
Also add :p flag to fiber/new, change implemntation of with-dyns, and
make meson build install static library by default.
2019-06-08 10:30:43 -04:00
Calvin Rose
e697cc3811
Make os/execute not leak memory on panics.
...
Since many calls can panic, it's best
to only use scratch memory for temporary values.
2019-06-01 23:38:10 -04:00
Calvin Rose
e1bd24c2ab
Make os/execute on windows closer to posix version
2019-05-31 15:02:44 -04:00
Calvin Rose
1f30ea66e9
Windows quick fix.
2019-05-31 13:45:39 -04:00
Calvin Rose
c43aaf8986
More work to os/execute.
...
Use environ when eflag not given. Also try to escape windows
command line strings correctly.
2019-05-31 13:44:14 -04:00
Calvin Rose
d005ac6888
Appease MSVC.
2019-05-30 19:21:11 -04:00
Calvin Rose
7fdb098a20
Add process.h.
2019-05-30 19:14:54 -04:00
Calvin Rose
a4a200e037
Spawn.h not found in windows.
2019-05-30 19:13:13 -04:00
Calvin Rose
46950a8cb3
Convert os/execute to use posix_spawn.
2019-05-30 18:40:10 -04:00
Calvin Rose
fd2d706e33
Add os/remove.
2019-05-29 11:31:19 -04:00
Andrew Chambers
ec43afb426
Minor documentation fixes.
2019-05-17 20:58:06 +12:00
Calvin Rose
73b81e0253
Fix os/date doc typo.
2019-04-23 22:43:51 -04:00
Calvin Rose
ee35786c8f
semicolon
2019-04-05 14:45:45 -04:00
Calvin Rose
ec6e2cfd62
os/stat returns nil if file does not exist.
2019-04-05 14:45:04 -04:00
Calvin Rose
cd6c009c03
Reformat and use new os/stat capabilities.
2019-04-01 11:21:45 -04:00
Calvin Rose
b15cf193a0
Update os/stat
...
os/stat can now take a keyword as the second argument
to avoid creating a table if one only wants on value
from stat.
2019-04-01 11:11:15 -04:00
Calvin Rose
e239980da7
Quasiquoting bracketed tuples.
2019-03-31 14:15:26 -04:00
Calvin Rose
1709bce77e
Add os/rm and os/rmdir
2019-03-30 15:39:24 -04:00
Calvin Rose
d6ba2de888
Fix os/dir on windows.
2019-03-30 13:46:52 -04:00
Calvin Rose
61c0a4bc87
Windows has different defines for file modes.
2019-03-30 13:09:35 -04:00
Calvin Rose
8af28d3fa5
Windows bump.
2019-03-30 13:06:24 -04:00
Calvin Rose
970923d0e5
Update os/dir for windows.
2019-03-30 13:01:57 -04:00
Calvin Rose
5d7dc0a57c
Add os/dir support for linux/posix.
2019-03-30 12:36:27 -04:00
Calvin Rose
c5090606a4
Add os/stat function.
...
Allows getting more information about files. This
is really useful for writing software that needs to inspect
the file system (like a static site generator). We still need
a way to iterate directories though.
2019-03-30 12:06:14 -04:00
Calvin Rose
bf2d9ae634
Mess with includes for os.c
2019-03-28 23:34:24 -04:00
Calvin Rose
53c7f2eedd
Add more os module functions.
2019-03-28 23:23:58 -04:00
Calvin Rose
2ea28f29b0
Shut up some warnings from clang's static analyzer.
...
Not particularly useful actually, by and large false positives.
2019-02-22 12:10:27 -05:00
Calvin Rose
9d4effc02e
Add make format to format code.
...
A consistent style should help with contributors and
readability. We use astyle as the formatter as can make a pretty
good approximation of the current style and my preferred style.
Astyle can be found at http://astyle.sourceforge.net/astyle.html
2019-02-19 20:51:34 -05:00
Calvin Rose
ed72dcf82d
Rename the header <janet/janet.h> to <janet.h>
...
Makes it easier to use and remember, and makes the
variable `module/*headerpath*` make more sense.
2019-02-18 20:13:35 -05:00
Calvin Rose
fe27df528c
Boot core library from image rather than source
...
This should speed up start time and reduce malloc/free
usage to about 15% of what is what previously for startup.
The current cost is slightly larger binary as the representaion
of the image is currently less compact than source code.
2019-02-08 00:44:30 -05:00
Calvin Rose
611543c48b
Add source amalgamation
...
The amalgamated source concatenates all sources
to a file janet.c which can be used for
embedding janet, much in the same way as sqlite
or mongoose.
2019-01-24 00:15:58 -05:00
Calvin Rose
795e7a9de8
Make os/date results more consistent.
2019-01-20 16:49:39 -05:00
Calvin Rose
2bbf9fdcc5
Add os/date to core library.
2019-01-20 14:34:33 -05:00
Calvin Rose
6f3bc3d577
Update copyright date, fix types, remove trailing whitespace.
2019-01-06 03:23:03 -05:00