Commit Graph

10 Commits

Author SHA1 Message Date
Érico Nogueira bd30334277 Manually set thread stack sizes.
8KB was empirically determined to work on musl. We can't go lower (musl
supports up to 2KB) because posix_spawn allocates a temporary stack for
vfork (via clone(2)) on its own stack.

This improves our resource consumption and increases the likeliness for
pthread_create to work even when there isn't a lot of free memory.

Using pthread_setattr_default_np isn't possible, because on musl it
doesn't allow us to go below the default thread stack size. This way is
also more portable.

We don't remove the guard pages entirely, because a shell prompt might
be active in attacker controlled directories, and it's a reasonable
protection against any stack overflow exploits that might appear.
2021-07-17 20:58:16 -03:00
Érico Rolim 46ea87ea21 Fix showing current path again.
Avoid unnecessary heap allocations (though we added new ones in main())
if possible by using a PATH_MAX buffer.

Check for PWD matching current directory ourselves, which allows us to
save a stat syscall, by re-using the stat(".") result to compare to
stat("$HOME"). Improve how we check if HOME is actually part of pwd -
previous would get confused with "${HOME}char", which should not get the
prompt to display '~'.

Use strtok_r to scan characters now. Writing directly to p() makes more
sense than writing chars to a buffer, so remove that.

I'm somewhat unhappy with the rpwd and mrpwd solution, since while
coding I forgot to set one or the other a couple of times. It would be
nice if I could "unconst" the variable at some point, though I greatly
dislike that pattern.
2021-03-07 04:17:23 -03:00
Érico Rolim cd48564223 Remove global variables from git.c.
Use a struct to handle the produced values and pass them around.
Also improve error handling very slightly, and free some memory.
2021-03-07 02:36:13 -03:00
Érico Rolim 4ca87587df Remove unnecessary usage of sig_atomic_t.
Member launched of struct threaded_task should be accessed after some
sort of synchronization happens (what we currently do is join the thread
that touches the struct), so it doesn't need to be an atomic variable.
2021-03-07 01:24:48 -03:00
Érico Rolim 815fdf1294 Fix hostname printing.
ssh doesn't set HOSTNAME in env, that has to be determined separately.
What indicates a ssh session are some SSH_* env vars.
2021-02-22 12:34:34 -03:00
Érico Rolim 14cb4cbed4 Avoid using any globals in language detection. 2021-02-22 05:00:11 -03:00
Érico Rolim 81c7f243a7 Add framework to display detected programming languages.
Very dumb initial C detection.
2021-02-22 04:43:40 -03:00
Érico Rolim dc4a59881c Enable git status reporting.
Also reorganize git.c to contain most of the implementation details,
main just calls the functions without any arguments.
2021-02-22 02:40:31 -03:00
Érico Rolim fdf2b43b34 Move output and path handling code outside main.
Temporarily add static to translation strings to allow compilation to
work.
2021-02-22 01:53:44 -03:00
Érico Rolim d8b6432c6b Fix git.h, move it to ep.h. 2021-02-22 01:43:22 -03:00