Commit Graph

1014 Commits

Author SHA1 Message Date
randomuser b3624e234c change default configuration file location 2022-11-27 19:17:14 +00:00
randomuser 9739b9a887 add .gitignore 2022-11-27 19:06:57 +00:00
Hiltjo Posthuma 60e402d0f2 improve comment: uppercase cdata -> CDATA 2022-08-26 21:55:35 +02:00
Hiltjo Posthuma 411f5e83c3 bump version to 1.6 2022-08-17 16:47:52 +02:00
Hiltjo Posthuma d69467dff3 sfeed_curses: fix a memleak caused by a mistake in refactoring the code
Introduced by a code cleanup/refactor in commit
59ba2ed29b
2022-08-17 01:34:10 +02:00
Hiltjo Posthuma b6731ae35b slightly improve some comments 2022-07-20 20:37:14 +02:00
Hiltjo Posthuma 59ba2ed29b sfeed_curses: cleanup code for handling read items from an URL file
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).
2022-07-17 12:46:34 +02:00
NRK 7b2bec5985 remove __dead code
this check is already done in util.h and is no longer needed after the
`sfeed_curses -> sfeed` merge.
2022-07-05 23:06:02 +02:00
Hiltjo Posthuma 6890a40099 sfeed_curses: write out plumbercmd argument in a verbose manner
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/
2022-07-05 15:57:35 +02:00
NRK 70007b61aa fix some typis
found via codespell

	$ codespell --ignore-regex Nd
2022-06-21 11:04:43 +02:00
Hiltjo Posthuma 4b97fc93a6 sfeed: reword a poorly-worded comment 2022-06-20 13:25:35 +02:00
Hiltjo Posthuma bd5a0f5d36 sfeed: fix a wrong comment 2022-06-20 13:18:43 +02:00
Hiltjo Posthuma 0f2ddea7cf README: add setsid example 2022-06-18 22:52:44 +02:00
Hiltjo Posthuma 8737035999 themes: simplify empty macros, remove do { } while(0)
Multiple function calls should still be nested in a do { } while(0), but this
is hopefully obvious looking at the other lines.

While testing, gcc with -O0 created the same binary.
clang added a single jmp instruction.
2022-06-06 11:03:29 +02:00
Hiltjo Posthuma cc3dd4534b sfeed_curses: processexit(): remove unneeded code for non-interactive processes
This was used in commit a58fa45f25 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.
2022-06-05 23:38:22 +02:00
Hiltjo Posthuma f8ef20b259 README: fix bug in an example for counting the new items of the last day
This should not use the plain-text URL file ($SFEED_URL_FILE).
2022-05-31 11:33:06 +02:00
Hiltjo Posthuma 6c0d824397 minicurses.h: remove unneeded include
In the past there was an ioctl() call in setupterm(), so this include is not
needed anymore.
2022-05-31 11:30:56 +02:00
Hiltjo Posthuma 41b46d0452 bump version to 1.5 2022-05-21 11:34:58 +02:00
Hiltjo Posthuma 0391bae406 README: make sure sfeed_update errors don't write to stderr
It would mess up the output since the progress bar writes to stderr aswell.
2022-05-19 21:32:42 +02:00
Hiltjo Posthuma e1676198f0 README: add progress indicator script 2022-05-14 20:31:18 +02:00
Hiltjo Posthuma d871d884d3 manual pages: reword a few things a bit more clearly 2022-05-14 20:31:15 +02:00
Hiltjo Posthuma 8b7c95d1a6 sfeed_curses: improve comment
Do not restart the syscall waitpid, explicitly mention not setting SA_RESTART.
2022-05-07 20:33:08 +02:00
Hiltjo Posthuma c64dff716e sfeed_curses: interrupt waitpid while interactive child program is running
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
2022-05-07 20:18:58 +02:00
Hiltjo Posthuma 78e5435937 sfeed_curses: close stdin for spawning a plumb program in non-interactive mode
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.
2022-05-05 10:11:05 +02:00
Hiltjo Posthuma f0ca847fca sfeed_curses.1: more details about signals and (non-)interactive programs
- SIGINT: reword, canceling the line editor is the exception.
- Document the order of signal handling.
- Document interactive and non-interactive behaviour in a separate section and
  in more detail.
  Remove repetition for each *_INTERACTIVE environment variable.
- Document SIGINT and SIGTERM exit status.
- Typo: "statusbar" -> "status bar".
- Reword a few sentences.

With additional changes and feedback from adc, thanks!
2022-05-04 20:43:59 +02:00
Hiltjo Posthuma 796e311b74 manual pages: properly escape some more backslashes
... and bump the date also.
2022-05-02 20:09:15 +02:00
Anders Damsgaard 06cd065b6e manual pages: properly escape backslashes
From the mdoc(7) extended introduction[0]:

>To output a backslash, use the escape sequence ‘\e’. Never use the
>escape sequence ‘\\’ in any context.

0: https://mandoc.bsd.lv/mdoc/intro/escaping.html
2022-05-02 20:07:19 +02:00
Hiltjo Posthuma c3f5dcec10 sfeed_curses.1: fix typo: automaticly -> automatically
Noticed by the Debian scanner for typos (typo-in-manual-page):
https://mentors.debian.net/package/sfeed/
2022-04-10 18:28:33 +02:00
Hiltjo Posthuma 7225f6f927 bump version to 1.4 2022-04-02 17:35:31 +02:00
Hiltjo Posthuma 031b279e81 sfeed_curses: code-style: mouse mode: just use a constant
No functional change intended. Just slightly more clear.
2022-04-02 13:54:49 +02:00
Hiltjo Posthuma f4c4b97bba sfeed_curses: line editor: handle SIGCHLD directly
This makes sure when processes exit they are reaped immediately (instead of
after closing the line editor).
2022-04-02 00:47:46 +02:00
Hiltjo Posthuma 3eb3533fae sfeed_curses: line editor, temporarily disable the mouse when using the line editor
This allows pasting in the terminal and also doesnt spam mouse events, which
are not useful here.
2022-04-02 00:32:28 +02:00
Hiltjo Posthuma b2d6839a8c sfeed_curses: don't use bitmasks to keep the states for signals
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
2022-04-01 21:29:19 +02:00
Hiltjo Posthuma 6279bf321e sfeed_curses: small code-style change 2022-04-01 00:57:49 +02:00
Hiltjo Posthuma f4cfa079c7 README: reflect example with the description 2022-04-01 00:57:34 +02:00
Hiltjo Posthuma b4344cc3b0 sfeed_curses: improve multiple signal handling
Keep a bitmask of the received signals and handle them all.
Also handle them in a particular order now.
2022-04-01 00:33:23 +02:00
Hiltjo Posthuma a6a8f29666 sfeed_curses: improve waiting on processes and reaping them
- 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
30a70fa2da 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).
2022-03-31 23:04:20 +02:00
Hiltjo Posthuma 3d4ad85bdd sfeed.c: rm ctype.h its not needed 2022-03-31 22:43:13 +02:00
Hiltjo Posthuma 275cc6c2d0 sfeed.1: add an example to convert to UTF-8 using iconv 2022-03-29 11:25:30 +02:00
Hiltjo Posthuma d5ee385b4b compatibility: reduce the assumption the builtin libc locale is ASCII-compatible
This is not clearly defined by the C99 standard.
Define ctype-like macros to force it to be ASCII / UTF-8 (not extended ASCII or
something like noticed on OpenBSD 3.8).

(In practise modern libc libraries are all ASCII and UTF-8-compatible. Otherwise
this would break many programs)
2022-03-29 11:03:54 +02:00
Hiltjo Posthuma 880256b8bf compatibility: replace iscntrl with own ISCNTRL macro
It is unspecified if the C locale iscntrl is compatible with ASCII or not.

Noticed when testing on OpenBSD 3.8 which uses extended ASCII and also uses the
C1 range for control-characters.  This breaks support with UTF-8.

Reference:
https://en.wikipedia.org/wiki/C0_and_C1_control_codes#C1_control_codes_for_general_use
C1 table.

Force an own definition of an ASCII-compatible control-character range since
sfeed expects input to be UTF-8 (or converted from iconv) and so output to be
UTF-8 aswell.
2022-03-28 18:36:20 +02:00
Hiltjo Posthuma a58fa45f25 sfeed_curses: fix-up from previous commit: properly initialize struct sigaction 2022-03-28 18:01:22 +02:00
Hiltjo Posthuma 30a70fa2da sfeed_curses: ignore SIGCHLD only for non-interactive programs
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."
2022-03-28 15:58:00 +02:00
Hiltjo Posthuma df2250aa19 sfeed_update: change return to exit in main
Pedantic change:

Make main more consistent since other functions in it exit too and main is not
supposed to return or used like that.
2022-03-28 13:07:58 +02:00
Hiltjo Posthuma 2a47f88faa update documentation of sfeed_update example and clarify return status
Change the example to reload the feeds anyway, even if one of the feeds
(temporarily) failed to update.
2022-03-28 12:58:09 +02:00
Hiltjo Posthuma ab0c25faa0 sfeed_curses: remove unneeded ctype.h include 2022-03-27 14:57:36 +02:00
Hiltjo Posthuma ebc33326e1 Revert "rm sys/types.h include and improve portability"
This reverts commit db1dcafd03.

This is needed. Tested on an (old) Slackware 11 install.
2022-03-27 14:57:05 +02:00
Hiltjo Posthuma b75648df80 sfeed_curses: tiny rewording in comment 2022-03-27 12:50:49 +02:00
Hiltjo Posthuma b2264d5892 sfeed_curses: processexit: do not set and reset SIGINT for non-interactive plumbing
Only set/override it in the interactive case.
Also add some comments.

No functional change intended.
2022-03-27 12:40:07 +02:00
Hiltjo Posthuma 33ae34357f sfeed_curses: avoid non-interactive plumb process becoming a zombie
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.
2022-03-27 12:32:31 +02:00