Merge branch 'master' into derek

This commit is contained in:
Derek Zhou 2020-05-18 14:47:20 -04:00 committed by GitHub
commit 5c7f9f9daa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 242 additions and 59 deletions

11
.builds/alpine.yml Normal file
View File

@ -0,0 +1,11 @@
image: alpine/edge
sources:
- https://github.com/martanne/abduco
tasks:
- build: |
cd abduco
./configure
make
- test: |
cd abduco
./testsuite.sh

11
.builds/debian.yml Normal file
View File

@ -0,0 +1,11 @@
image: debian/stable
sources:
- https://github.com/martanne/abduco
tasks:
- build: |
cd abduco
./configure
make
- test: |
cd abduco
./testsuite.sh

11
.builds/freebsd.yml Normal file
View File

@ -0,0 +1,11 @@
image: freebsd/latest
sources:
- https://github.com/martanne/abduco
tasks:
- build: |
cd abduco
./configure
make
- test: |
cd abduco
./testsuite.sh

11
.builds/openbsd.yml Normal file
View File

@ -0,0 +1,11 @@
image: openbsd/latest
sources:
- https://github.com/martanne/abduco
tasks:
- build: |
cd abduco
./configure
make
- test: |
cd abduco
./testsuite.sh

46
.github/workflows/coverity-scan.yml vendored Normal file
View File

@ -0,0 +1,46 @@
name: Coverity Scan
env:
PROJECT: abduco
on:
schedule:
- cron: '0 0 * * 0' # once a week
jobs:
scan:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Download Coverity Build Tool
run: |
wget -q https://scan.coverity.com/download/cxx/linux64 --post-data "token=$TOKEN&project=martanne/${PROJECT}" -O cov-analysis-linux64.tar.gz
mkdir cov-analysis-linux64
tar xzf cov-analysis-linux64.tar.gz --strip 1 -C cov-analysis-linux64
env:
TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}
- name: Configure
run: ./configure
- name: Build with cov-build
run: |
export PATH=$(pwd)/cov-analysis-linux64/bin:$PATH
cov-build --dir cov-int make
- name: Submit the result to Coverity Scan
run: |
tar czvf ${PROJECT}.tgz cov-int
curl \
--form project=martanne/${PROJECT} \
--form token=$TOKEN \
--form email=mat@brain-dump.org \
--form file=@${PROJECT}.tgz \
--form version=trunk \
--form description="`./${PROJECT} -v`" \
https://scan.coverity.com/builds?project=martanne/${PROJECT}
env:
TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}

44
.github/workflows/man.yml vendored Normal file
View File

@ -0,0 +1,44 @@
name: Manual
env:
PROJECT: abduco
on:
push:
paths:
- '*.1'
jobs:
man:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Dependency
run: sudo apt install mandoc
- name: Manual generation
run: |
mkdir man
sed -e "s/VERSION/$(git describe --always)/" ${PROJECT}.1 | \
mandoc -W warning -T utf8 -T html -O man=%N.%S.html -O style=mandoc.css 1> \
"man/${PROJECT}.1.html" || true
wget 'https://cvsweb.bsd.lv/~checkout~/mandoc/mandoc.css?rev=1.46&content-type=text/plain' -O man/mandoc.css
ln -sf "${PROJECT}.1.html" man/index.html
- name: Upload
env:
DEPLOY_TOKEN: ${{ secrets.GIT_DEPLOY_TOKEN }}
run: |
git clone --depth=1 --single-branch --branch gh-pages "https://x-access-token:${DEPLOY_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" /tmp/gh-pages
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
mkdir -p /tmp/gh-pages/man
rm -f /tmp/gh-pages/man/*
cp -av man/*.html /tmp/gh-pages/man/
cp -av man/*.css /tmp/gh-pages/man/
cd /tmp/gh-pages
git add -A && git commit --allow-empty -am "Publishing from ${GITHUB_REPOSITORY} ${GITHUB_SHA}"
git push origin gh-pages

16
.gitignore vendored
View File

@ -1,7 +1,9 @@
# normal ignores /config.h
.* /config.mk
*.[ao] /abduco
*.lo *.css
*.so *.gcda
tags *.gcno
!.gitignore *.gcov
*.html
*.o

View File

@ -8,6 +8,10 @@ CFLAGS_STD += -DVERSION=\"${VERSION}\"
LDFLAGS_STD ?= -lc -lutil LDFLAGS_STD ?= -lc -lutil
STRIP ?= strip STRIP ?= strip
INSTALL ?= install
PREFIX ?= /usr/local
SHAREDIR ?= ${PREFIX}/share
SRC = abduco.c SRC = abduco.c
@ -33,22 +37,31 @@ dist: clean
@echo creating dist tarball @echo creating dist tarball
@git archive --prefix=abduco-${VERSION}/ -o abduco-${VERSION}.tar.gz HEAD @git archive --prefix=abduco-${VERSION}/ -o abduco-${VERSION}.tar.gz HEAD
install: abduco installdirs:
@echo stripping executable @${INSTALL} -d ${DESTDIR}${PREFIX}/bin \
@${STRIP} abduco ${DESTDIR}${MANPREFIX}/man1
install: abduco installdirs
@echo installing executable file to ${DESTDIR}${PREFIX}/bin @echo installing executable file to ${DESTDIR}${PREFIX}/bin
@mkdir -p ${DESTDIR}${PREFIX}/bin @${INSTALL} -m 0755 abduco ${DESTDIR}${PREFIX}/bin
@cp -f abduco ${DESTDIR}${PREFIX}/bin
@chmod 755 ${DESTDIR}${PREFIX}/bin/abduco
@echo installing manual page to ${DESTDIR}${MANPREFIX}/man1 @echo installing manual page to ${DESTDIR}${MANPREFIX}/man1
@mkdir -p ${DESTDIR}${MANPREFIX}/man1 @mkdir -p ${DESTDIR}${MANPREFIX}/man1
@sed "s/VERSION/${VERSION}/g" < abduco.1 > ${DESTDIR}${MANPREFIX}/man1/abduco.1 @sed "s/VERSION/${VERSION}/g" < abduco.1 > ${DESTDIR}${MANPREFIX}/man1/abduco.1
@chmod 644 ${DESTDIR}${MANPREFIX}/man1/abduco.1 @chmod 644 ${DESTDIR}${MANPREFIX}/man1/abduco.1
install-strip: install
${STRIP} ${DESTDIR}${PREFIX}/bin/abduco
install-completion:
@echo installing zsh completion file to ${DESTDIR}${SHAREDIR}/zsh/site-functions
@install -Dm644 contrib/abduco.zsh ${DESTDIR}${SHAREDIR}/zsh/site-functions/_abduco
uninstall: uninstall:
@echo removing executable file from ${DESTDIR}${PREFIX}/bin @echo removing executable file from ${DESTDIR}${PREFIX}/bin
@rm -f ${DESTDIR}${PREFIX}/bin/abduco @rm -f ${DESTDIR}${PREFIX}/bin/abduco
@echo removing manual page from ${DESTDIR}${MANPREFIX}/man1 @echo removing manual page from ${DESTDIR}${MANPREFIX}/man1
@rm -f ${DESTDIR}${MANPREFIX}/man1/abduco.1 @rm -f ${DESTDIR}${MANPREFIX}/man1/abduco.1
@echo removing zsh completion file from ${DESTDIR}${SHAREDIR}/zsh/site-functions
@rm -f ${DESTDIR}${SHAREDIR}/zsh/site-functions/_abduco
.PHONY: all clean dist install uninstall debug .PHONY: all clean dist install installdirs install-strip install-completion uninstall debug

View File

@ -7,9 +7,9 @@ run in the background - and then later reattached. Together with
[dvtm](http://www.brain-dump.org/projects/dvtm) it provides a [dvtm](http://www.brain-dump.org/projects/dvtm) it provides a
simpler and cleaner alternative to tmux or screen. simpler and cleaner alternative to tmux or screen.
![abduco+dvtm demo](https://raw.githubusercontent.com/martanne/abduco/gh-pages/screencast.gif) ![abduco+dvtm demo](https://raw.githubusercontent.com/martanne/abduco/gh-pages/screencast.gif#center)
abduco is in many ways very similar to [dtach]("http://dtach.sf.net) abduco is in many ways very similar to [dtach](http://dtach.sf.net)
but is a completely independent implementation which is actively maintained, but is a completely independent implementation which is actively maintained,
contains no legacy code, provides a few additional features, has a contains no legacy code, provides a few additional features, has a
cleaner, more robust implementation and is distributed under the cleaner, more robust implementation and is distributed under the
@ -34,23 +34,13 @@ cleaner, more robust implementation and is distributed under the
## Download ## Download
Either download the latest source tarball Either download the latest [source tarball](https://github.com/martanne/abduco/releases),
[abduco-0.5.tar.gz](http://www.brain-dump.org/projects/abduco/abduco-0.5.tar.gz)
with sha1sum
37c51a0d5c3dd216251d84d5c1b550f119ad53c9 abduco-0.5.tar.gz
compile and install it compile and install it
./configure && make && sudo make install ./configure && make && sudo make install
or use one of the distribution provided binary packages: or use one of the distribution provided
[binary packages](https://repology.org/project/abduco/packages).
* [Debian](https://packages.debian.org/search?keywords=abduco)
* [Fedora](https://admin.fedoraproject.org/pkgdb/package/abduco/)
* [Gentoo](http://packages.gentoo.org/package/app-misc/abduco/)
* [Ubuntu](http://packages.ubuntu.com/search?keywords=abduco)
* [Mac OS X](http://www.braumeister.org/formula/abduco) via homebrew
## Quickstart ## Quickstart
@ -167,21 +157,14 @@ command line options.
## Development ## Development
You can always fetch the current code base from the git repository. You can always fetch the current code base from the git repository
located at [Github](https://github.com/martanne/abduco/) or
[Sourcehut](https://git.sr.ht/~martanne/abduco).
git clone https://github.com/martanne/abduco.git If you have comments, suggestions, ideas, a bug report, a patch or
something else related to abduco then write to the
or
git clone git://repo.or.cz/abduco.git
If you have comments, suggestions, ideas, a bug report, a patch or something
else related to abduco then write to the
[suckless developer mailing list](http://suckless.org/community) [suckless developer mailing list](http://suckless.org/community)
or contact me directly mat[at]brain-dump.org. or contact me directly.
[![Build Status](https://travis-ci.org/martanne/abduco.svg?branch=master)](https://travis-ci.org/martanne/abduco)
[![Coverity Scan Build Status](https://scan.coverity.com/projects/4285/badge.svg)](https://scan.coverity.com/projects/4285)
### Debugging ### Debugging
@ -194,8 +177,8 @@ to temporary files as follows:
If you want to run client and server with one command (e.g. using the `-c` If you want to run client and server with one command (e.g. using the `-c`
option) then within `gdb` the option `set follow-fork-mode {child,parent}` option) then within `gdb` the option `set follow-fork-mode {child,parent}`
might be useful. Similarly to get a syscall trace `strace -o abduco -ff [abduco-cmd]` might be useful. Similarly to get a syscall trace `strace -o abduco -ff
proved to be handy. [abduco-cmd]` proved to be handy.
## License ## License

View File

@ -60,16 +60,17 @@ are relayed to the command supervised by the server.
.Pp .Pp
.Nm .Nm
operates on the raw I/O byte stream without interpreting any terminal operates on the raw I/O byte stream without interpreting any terminal
escape sequences. As a consequence the terminal state is not preserved escape sequences.
across sessions. If this functionality is desired, it should be provided As a consequence the terminal state is not preserved across sessions.
by another utility such as If this functionality is desired, it should be provided by another
utility such as
.Xr dvtm 1 . .Xr dvtm 1 .
. .
.Ss ACTIONS .Ss ACTIONS
. .
If no command line arguments are given, all currently active sessions are If no command line arguments are given, all currently active sessions are
listed sorted by their respective creation date. Lines starting with an listed sorted by their respective creation date.
asterisk Lines starting with an asterisk
.Pq * .Pq *
indicate that at least one client is currently connected. indicate that at least one client is currently connected.
A plus sign A plus sign
@ -101,7 +102,8 @@ Additionally the following options can be provided to further tweak
the behavior. the behavior.
.Bl -tag -width indent .Bl -tag -width indent
.It Fl e Ar detachkey .It Fl e Ar detachkey
Set the key to detach. Defaults to Set the key to detach.
Defaults to
.Aq Ctrl+\e .Aq Ctrl+\e
which is specified as ^\\ i.e. Ctrl is represented as a caret which is specified as ^\\ i.e. Ctrl is represented as a caret
.Pq ^ . .Pq ^ .
@ -111,7 +113,8 @@ after showing its exit status.
.It Fl l .It Fl l
Attach with the lowest priority, meaning this client will be the last to control the size. Attach with the lowest priority, meaning this client will be the last to control the size.
.It Fl p .It Fl p
Pass through content of standard input to the session. Implies the Pass through content of standard input to the session.
Implies the
.Fl q .Fl q
and and
.Fl l .Fl l
@ -225,7 +228,7 @@ Or in a slightly more interactive fashion.
.Xr tmux 1 , .Xr tmux 1 ,
.Xr screen 1 .Xr screen 1
. .
.Sh AUTHOR .Sh AUTHORS
.Nm .Nm
is written by is written by
.An Marc André Tanner Aq mat at brain-dump.org .An Marc André Tanner Aq mat at brain-dump.org

View File

@ -463,7 +463,7 @@ static bool create_session(const char *name, char * const argv[]) {
sa.sa_handler = SIG_IGN; sa.sa_handler = SIG_IGN;
sigaction(SIGPIPE, &sa, NULL); sigaction(SIGPIPE, &sa, NULL);
sigaction(SIGHUP, &sa, NULL); sigaction(SIGHUP, &sa, NULL);
if (chdir("/") == -1) /* should not happen, just to make the compiler happy */ if (chdir("/") == -1)
_exit(EXIT_FAILURE); _exit(EXIT_FAILURE);
#ifdef NDEBUG #ifdef NDEBUG
int fd = open("/dev/null", O_RDWR); int fd = open("/dev/null", O_RDWR);
@ -501,8 +501,7 @@ static bool create_session(const char *name, char * const argv[]) {
return false; return false;
default: /* parent = client process */ default: /* parent = client process */
close(client_pipe[1]); close(client_pipe[1]);
int status; while (waitpid(pid, NULL, 0) == -1 && errno == EINTR);
wait(&status); /* wait for first fork */
ssize_t len = read_all(client_pipe[0], errormsg, sizeof(errormsg)); ssize_t len = read_all(client_pipe[0], errormsg, sizeof(errormsg));
if (len > 0) { if (len > 0) {
write_all(STDERR_FILENO, errormsg, len); write_all(STDERR_FILENO, errormsg, len);
@ -758,6 +757,7 @@ int main(int argc, char *argv[]) {
die("create-session"); die("create-session");
if (action == 'n') if (action == 'n')
break; break;
/* fall through */
case 'a': case 'a':
if (!attach_session(server.session_name, true)) if (!attach_session(server.session_name, true))
die("attach-session"); die("attach-session");

35
contrib/abduco.zsh Normal file
View File

@ -0,0 +1,35 @@
#compdef abduco
typeset -A opt_args
_abduco_sessions() {
declare -a sessions
sessions=( $(abduco | sed '1d;s/.*\t[0-9][0-9]*\t//') )
_describe -t session 'session' sessions
}
_abduco_firstarg() {
if (( $+opt_args[-a] || $+opt_args[-A] )); then
_abduco_sessions
elif (( $+opt_args[-c] || $+opt_args[-n] )); then
_guard "^-*" 'session name'
elif [[ -z $words[CURRENT] ]]; then
compadd "$@" -S '' -- -
fi
}
_arguments -s \
'(-a -A -c -n -f)-a[attach to an existing session]' \
'(-a -A -c -n)-A[attach to a session, create if does not exist]' \
'(-a -A -c -n -l)-c[create a new session and attach to it]' \
'(-a -A -c -n -l)-n[create a new session but do not attach to it]' \
'-e[set the detachkey (default: ^\\)]:detachkey' \
'(-a)-f[force create the session]' \
'(-q)-p[pass-through mode]' \
'-q[be quiet]' \
'-r[read-only session, ignore user input]' \
'(-c -n)-l[attach with the lowest priority]' \
'(-)-v[show version information and exit]' \
'1: :_abduco_firstarg' \
'2:command:_path_commands' \
'*:: :{ shift $((CURRENT-3)) words; _precommand; }'

View File

@ -7,6 +7,9 @@ ABDUCO_OPTS="-e ^\\"
[ ! -z "$1" ] && ABDUCO="$1" [ ! -z "$1" ] && ABDUCO="$1"
[ ! -x "$ABDUCO" ] && echo "usage: $0 /path/to/abduco" && exit 1 [ ! -x "$ABDUCO" ] && echo "usage: $0 /path/to/abduco" && exit 1
TESTS_OK=0
TESTS_RUN=0
detach() { detach() {
sleep 1 sleep 1
printf "" printf ""
@ -74,12 +77,14 @@ run_test_attached() {
local output="$name.out" local output="$name.out"
local output_expected="$name.expected" local output_expected="$name.expected"
TESTS_RUN=$((TESTS_RUN + 1))
echo -n "Running test attached: $name " echo -n "Running test attached: $name "
expected_abduco_attached_output "$name" "$cmd" > "$output_expected" 2>&1 expected_abduco_attached_output "$name" "$cmd" > "$output_expected" 2>&1
$ABDUCO -c "$name" $cmd 2>&1 | sed 's/.$//' > "$output"
if diff -u "$output_expected" "$output" && check_environment; then if $ABDUCO -c "$name" $cmd 2>&1 | sed 's/.$//' > "$output" && sleep 1 &&
diff -u "$output_expected" "$output" && check_environment; then
rm "$output" "$output_expected" rm "$output" "$output_expected"
TESTS_OK=$((TESTS_OK + 1))
echo "OK" echo "OK"
return 0 return 0
else else
@ -97,6 +102,7 @@ run_test_detached() {
local output="$name.out" local output="$name.out"
local output_expected="$name.expected" local output_expected="$name.expected"
TESTS_RUN=$((TESTS_RUN + 1))
echo -n "Running test detached: $name " echo -n "Running test detached: $name "
expected_abduco_detached_output "$name" "$cmd" > "$output_expected" 2>&1 expected_abduco_detached_output "$name" "$cmd" > "$output_expected" 2>&1
@ -104,6 +110,7 @@ run_test_detached() {
$ABDUCO -a "$name" 2>&1 | sed 's/.$//' > "$output" && $ABDUCO -a "$name" 2>&1 | sed 's/.$//' > "$output" &&
diff -u "$output_expected" "$output" && check_environment; then diff -u "$output_expected" "$output" && check_environment; then
rm "$output" "$output_expected" rm "$output" "$output_expected"
TESTS_OK=$((TESTS_OK + 1))
echo "OK" echo "OK"
return 0 return 0
else else
@ -121,6 +128,7 @@ run_test_attached_detached() {
local output="$name.out" local output="$name.out"
local output_expected="$name.expected" local output_expected="$name.expected"
TESTS_RUN=$((TESTS_RUN + 1))
echo -n "Running test: $name " echo -n "Running test: $name "
$cmd >/dev/null 2>&1 $cmd >/dev/null 2>&1
expected_abduco_epilog "$name" $? > "$output_expected" 2>&1 expected_abduco_epilog "$name" $? > "$output_expected" 2>&1
@ -129,6 +137,7 @@ run_test_attached_detached() {
$ABDUCO -a "$name" 2>&1 | tail -1 | sed 's/.$//' > "$output" && $ABDUCO -a "$name" 2>&1 | tail -1 | sed 's/.$//' > "$output" &&
diff -u "$output_expected" "$output" && check_environment; then diff -u "$output_expected" "$output" && check_environment; then
rm "$output" "$output_expected" rm "$output" "$output_expected"
TESTS_OK=$((TESTS_OK + 1))
echo "OK" echo "OK"
return 0 return 0
else else
@ -144,6 +153,7 @@ run_test_dvtm() {
return 0; return 0;
fi fi
TESTS_RUN=$((TESTS_RUN + 1))
local name="dvtm" local name="dvtm"
local output="$name.out" local output="$name.out"
local output_expected="$name.expected" local output_expected="$name.expected"
@ -152,6 +162,7 @@ run_test_dvtm() {
if dvtm_session | $ABDUCO -c "$name" > "$output" 2>&1 && if dvtm_session | $ABDUCO -c "$name" > "$output" 2>&1 &&
diff -u "$output_expected" "$output" && check_environment; then diff -u "$output_expected" "$output" && check_environment; then
rm "$output" "$output_expected" rm "$output" "$output_expected"
TESTS_OK=$((TESTS_OK + 1))
echo "OK" echo "OK"
return 0 return 0
else else
@ -162,8 +173,8 @@ run_test_dvtm() {
test_non_existing_command || echo "Execution of non existing command FAILED" test_non_existing_command || echo "Execution of non existing command FAILED"
run_test_attached "seq" "seq 1 1000" run_test_attached "awk" "awk 'BEGIN {for(i=1;i<=1000;i++) print i}'"
run_test_detached "seq" "seq 1 1000" run_test_detached "awk" "awk 'BEGIN {for(i=1;i<=1000;i++) print i}'"
run_test_attached "false" "false" run_test_attached "false" "false"
run_test_detached "false" "false" run_test_detached "false" "false"
@ -200,3 +211,5 @@ run_test_attached_detached "attach-detach" "./long-running.sh"
rm ./long-running.sh rm ./long-running.sh
run_test_dvtm run_test_dvtm
[ $TESTS_OK -eq $TESTS_RUN ]