Age | Commit message (Collapse) | Author |
|
for lazyloaded items
Fix the code pattern of freeing the line when getline returns -1 but no error
flag is set on the stream (such as EOF).
Note that on errors (even ENOMEM: out-of-memory) an error flag is set on the
stream and the process would exit and clean up all it's resources.
This would be very hard to trigger. The following conditions would have to be
true:
* Lazyloading of items is enabled: SFEED_LAZYLOAD=1 is set.
* Items of the feed are read and their offsets stored.
* The line is read/lazy-loaded again by it's offset but returns EOF (not a read
error) this time.
This could maybe happen if the feed file was changed and made smaller while
sfeed_curses is running and the remembered offset is now beyond the file.
Note that the sfeed_curses(1) man page describes a workaround for a similar
condition by sending SIGHUP if the sfeed(5) data was changed to reload the feed
file.
References:
* https://man.openbsd.org/getline
"It is the responsibility of the caller to free(3) *lineptr when it is no
longer needed. Even when it fails, getdelim() may update *lineptr."
* https://pubs.opengroup.org/onlinepubs/9699919799/functions/getline.html
|
|
This fixes the keys on the sun-color console on OpenIndiana/Illumos/OpenSolaris
(and other systems using these keys).
See also the table:
https://invisible-island.net/xterm/ctlseqs/ctlseqs.html
Section "Non-Function Keys".
|
|
This fixes the page up and page down keys in the cons25 console on
DragonFlyBSD.
See also the table:
https://invisible-island.net/xterm/ctlseqs/ctlseqs.html
Section "Non-Function Keys".
|
|
This was a copy-pasta.
|
|
Introduced by a code cleanup/refactor in commit
59ba2ed29bcbe67de6e9ee1e7fb18744f7490c22
|
|
|
|
This makes it easier to reuse the code from reading plain-text list of items
from a file and uses a struct urls to keep its state in a cleaner way.
+ some small code-style improvements and reshuffling.
Inspired by a question from NRK by mail about implementing a "read later"
feature.
(A quick local experiment shows it can be done in ~70 lines of added code).
|
|
this check is already done in util.h and is no longer needed after the
`sfeed_curses -> sfeed` merge.
|
|
Write it in a more verbose, clear and C90-style manner.
This workarounds a bug in scc too (reported upstream and will be fixed of
course). All tools in sfeed can now be compiled with minicurses-mode with the
scc compiler and musl libc without any modifications needed.
scc: http://www.simple-cc.org/
|
|
This was used in commit a58fa45f25da4f18d7b8c1a815884f67b965406f and previous,
but the code for non-interactive process cleanup was later removed, so clearing
the struct is not not needed anymore, because it is unused.
|
|
Do not restart the syscall waitpid, explicitly mention not setting SA_RESTART.
|
|
This now handles SIGTERM on sfeed_curses properly while an interactive child program is running.
Test-case program:
https://git.codemadness.org/sfeed_tests/commit/cd4268d4f71b5d7ab0df593d95e70188475d76bb.html
|
|
This is only for plumbing in non-interactive mode in forkexec(), but not piping
content.
Probably obvious what the descriptors are, but also add a few comments to dup2
of the file descriptors (stdin, stdout, stderr).
To reproduce a behaviour:
Plumb script:
#!/bin/sh
dmenu
Then launch it:
SFEED_PLUMB_INTERACTIVE=0 SFEED_PLUMB=thescript sfeed_curses ~/.sfeed/feeds/*
The program now waits on input while in non-interactive mode and only seems to
hang.
After:
The program starts but just has no input passed to it.
|
|
No functional change intended. Just slightly more clear.
|
|
This makes sure when processes exit they are reaped immediately (instead of
after closing the line editor).
|
|
editor
This allows pasting in the terminal and also doesnt spam mouse events, which
are not useful here.
|
|
Reported by Leon Fisher, thanks!
"Each signal should have its own sig_atomic_t variable if you want to
keep state for all of them independently."
A similar issue was referenced in a OpenBSD tech mailinglist thread:
https://marc.info/?l=openbsd-tech&m=162940120614641&w=2
|
|
|
|
Keep a bitmask of the received signals and handle them all.
Also handle them in a particular order now.
|
|
- Wait on the exact process id and get its status.
- Handle SIGCHLD explicitly and reap zombie children: ignoring them by using
sigaction(SIGCHLD, &sa, NULL); would be racy in this case because sfeed_curses
has interactive and non-interactive programs.
Note while testing: if the markread program would be slow and in the meantime a
plumb process would exit. This signal is now pending and is a zombie process
until the SIGCHLD signal can be processed. This is fine.
This also fixes a regression from commit
30a70fa2dab1925b0eaea04f67e3f86b360386dd because SIGCHLD was ignored in the
parent for interactive processes aswell. This broke reading the exit status of
the markread program, reproducable by plumbing an item and then trying to mark
it as read (with SFEED_URL_FILE set).
|
|
|
|
This is a regression from the introduced change.
Else wait(&status) returned -1 and status was uninitialized.
The status of the returned program in the markread() function is used to
visually show it as read/unread. If the program failed it is assumed the
program could not mark it and so it is visually unchanged.
Just to be sure also initialize status to -1 (which can never happen normally)
since the exitstatus range is 0-255.
https://man.openbsd.org/wait#ERRORS
[ECHILD]: "No status from the terminated child process is available because the calling
process has asked the system to discard such status by ignoring the signal
SIGCHLD or setting the flag SA_NOCLDWAIT for that signal."
|
|
|
|
This reverts commit db1dcafd03997127f2cbc82376e2cc8df9b77356.
This is needed. Tested on an (old) Slackware 11 install.
|
|
|
|
plumbing
Only set/override it in the interactive case.
Also add some comments.
No functional change intended.
|
|
From POSIX:
Consequences of Process Termination:
https://pubs.opengroup.org/onlinepubs/9699919799/functions/_Exit.html#tag_16_01_03_01
"
[XSI] [Option Start] If the parent process of the calling process has set its
SA_NOCLDWAIT flag or has set the action for the SIGCHLD signal to SIG_IGN:
The process' status information (see Status Information), if any, shall be
discarded.
The lifetime of the calling process shall end immediately. If SA_NOCLDWAIT is
set, it is implementation-defined whether a SIGCHLD signal is sent to the
parent process.
If a thread in the parent process of the calling process is blocked in wait(),
waitpid(), or waitid(), and the parent process has no remaining child processes
in the set of waited-for children, the wait(), waitid(), or waitpid() function
shall fail and set errno to [ECHILD].
"
Noticed on Linux (but not on OpenBSD).
To reproduce:
- SFEED_PLUMBER_INTERACTIVE=0 SFEED_PLUMBER="less" sfeed_curses ~/.sfeed/feeds/*
- Then open and close the child program.
- Notice it becoming a zombie or "<defunct>" in the process table.
|
|
This include is not needed. It was intended for ssize_t but this is already
defined by stdio.h for getline().
|
|
First it expected a single digit number, but this way it makes it more easy and
logical to add Sun function keys: ESC [ num z
For archive/reference Sun function keys relevant to sfeed_curses:
num =
214: home
216: page up
220: end
222: page down
Noticed on OpenIndiana/Illumos.
|
|
This should also suppress a compiler warning of an unchecked write() return
value.
|
|
Use errx, time(NULL) does not set errno. For sfeed_curses reset errno so it
doesn't print a random error if it failed.
POSIX recommends checking against (time_t)-1 on failure.
Note that some implementation, like the OpenBSD man page says time() cannot
fail.
|
|
Otherwise a character like \xa0 (160) would be negative and goto the event,
since a negative return value in readch() is used for errors or reserved for
signal handling.
Noticed while testing mouse X10 encoding with extended buttons, like button 7:
SFEED_AUTOCMD="l$(printf '\x1b[M\xa0!!')j" ./sfeed_curses ~/.sfeed/feeds/*
|
|
On an unknown or invalid sequence just use the key handling like the other keys
do.
|
|
When reading data from stdin and changing the URL file externally in some way
and then pressing 'R' would not redraw (and highlight/unhighlight) the marked
items.
|
|
vdprintf() was changed back to vfprintf() in commit 06bb4583, but the write was
not changed.
Change it to be more consistent and use the stdio buffered functions/macro.
|
|
Add autocmd comment.
|
|
\x1b[1~ home (putty and some terminals).
\x1b[7~ urxvt home.
\x1b[8~ urxvt end.
Refactor repeated code also.
|
|
Some curses implementations have tparm(char *) (BSD and older ncurses), some
have tparm(const char *).
The older POSIX specification had: tparm(char *):
https://pubs.opengroup.org/onlinepubs/7908799/xcurses/term.h.html
Just cast it to char *. The terminfo variables are defined elsewhere so it
should be safe.
Also remove an unnecesary cast in minicurses.
Hopefully this satisfies all curses variants and versions now.
|
|
Older POSIX standards also defined it as a char * parameter (not const char *)
for tparm().
https://pubs.opengroup.org/onlinepubs/7908799/xcurses/term.h.html
|
|
This makes atleast feeds with simple ASCII work.
|
|
This fixes a compile error tested with HaikuOS 32-bit (gcc2h, based on gcc
2.95).
It also suppresses a false-positive warning of an unused forkexec function in
cppcheck.
|
|
|
|
This replaces the current J and K keybind, which was rarely useful.
Thanks to IanJ for the suggestion and feedback!
|
|
|
|
|
|
|
|
|
|
|
|
When a new URL file is used with no URL entries then NULL is passed to qsort()
and bsearch(). This is reported by clang UBsan as undefined behaviour
(debatable), but no issue in practise with many implementations. Fix it anyway.
To reproduce with clang UBsan:
Compile with clang or gcc with CFLAGS and LDFLAGS -fsanitize=undefined
touch /tmp/urls # new file which should be empty.
SFEED_URL_FILE=/tmp/urls sfeed_curses 2>/tmp/log
^D
q
cat /tmp/log
|
|
|