diff options
| author | Sean Kurtz <seankurtz75@gmail.com> | 2026-11-24 23:58:40 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-11-24 23:58:40 -0600 |
| commit | 805ac9728df933f41fafb168bccd7d3107146527 (patch) | |
| tree | f5e1cd404d2750068708e02002aa19dab9a84359 | |
| parent | 7d98bfa40e112c099e9a598656bd2203001570e1 (diff) | |
| parent | 2af0e2310412b8d95cad98cafb2f7b69cb753507 (diff) | |
| download | whoson-805ac9728df933f41fafb168bccd7d3107146527.tar.gz | |
Merge pull request #14 from skurtz97/release/1.0.0
Release 1.0.0: --version, CI and release automation, templates, changelog
| -rw-r--r-- | .github/ISSUE_TEMPLATE/bug_report.yml | 55 | ||||
| -rw-r--r-- | .github/ISSUE_TEMPLATE/config.yml | 1 | ||||
| -rw-r--r-- | .github/PULL_REQUEST_TEMPLATE.md | 12 | ||||
| -rw-r--r-- | .github/workflows/ci.yml | 39 | ||||
| -rw-r--r-- | .github/workflows/release.yml | 45 | ||||
| -rw-r--r-- | CHANGELOG.md | 21 | ||||
| -rw-r--r-- | CONTRIBUTING.md | 50 | ||||
| -rw-r--r-- | Makefile | 5 | ||||
| -rw-r--r-- | README.md | 28 | ||||
| -rw-r--r-- | whoson.c | 14 |
10 files changed, 267 insertions, 3 deletions
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000..48c07e1 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,55 @@ +name: Bug report +description: whoson printed the wrong thing, or nothing at all +labels: [bug] +body: + - type: markdown + attributes: + value: | + whoson only reads two console displays, so the most useful thing you + can attach is what those displays said. On an operator console: + `D TS,A` for TSO/E sessions, `D OMVS,A=ALL` for processes. + + - type: textarea + id: happened + attributes: + label: What happened + description: Paste the whoson output, and the display it disagrees with. + render: text + validations: + required: true + + - type: textarea + id: expected + attributes: + label: What you expected instead + validations: + required: true + + - type: input + id: version + attributes: + label: whoson --version + placeholder: whoson 1.0.0 + validations: + required: true + + - type: input + id: system + attributes: + label: z/OS release and ZOAU level + description: The `uname -a` output, and the ZOAU level (`pkglist`, + or the install directory). + placeholder: z/OS 3.1, ZOAU 1.3.4 + validations: + required: true + + - type: dropdown + id: build + attributes: + label: How it was built + options: + - make install, from a release tag + - make, from a git checkout + - something else (say so above) + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..3ba13e0 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1 @@ +blank_issues_enabled: false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..6b87a5b --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,12 @@ +# Pull request + +## What changed + +## How it was checked + +- [ ] `make` is warning-free on z/OS with IBM Open XL +- [ ] `make check` (heap checker, storage report) passes +- [ ] `clang-format --dry-run -Werror whoson.c` passes +- [ ] ran on this system and compared with `D TS,A` / `D OMVS,A=ALL` + +If a display field or column changed, say what the console showed. diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..de6ccb1 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,39 @@ +name: ci + +on: + push: + branches: [main] + pull_request: + +permissions: + contents: read + +jobs: + format: + name: clang-format + runs-on: ubuntu-latest + env: + # Pinned on purpose: clang-format moves line breaks between releases, and + # a gate that goes red on a tool upgrade says nothing about the change. + # Bump this together with .clang-format. + CLANG_FORMAT_VERSION: 23.1.5 + steps: + # v7.0.1, pinned to a commit: a tag can be repointed at other code. + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 + with: + persist-credentials: false + - run: pip install "clang-format==$CLANG_FORMAT_VERSION" + - run: clang-format --dry-run --Werror whoson.c + + makefile: + name: makefile + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 + with: + persist-credentials: false + # The build itself needs z/OS and the ZOAU headers, so this job only + # proves that the Makefile parses under GNU make and that each recipe is + # well formed. -n runs nothing. + - run: make -n all + - run: make -n install check list diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..9874865 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,45 @@ +name: release + +# Pushing v1.2.3 creates the release and attaches the source archive. There is +# no binary: whoson links against the ZOAU 64-bit DLL and only builds on z/OS, +# which no hosted runner provides. +on: + push: + tags: ['v[0-9]*'] + +permissions: + contents: write + +jobs: + release: + runs-on: ubuntu-latest + steps: + # v7.0.1, pinned to a commit: a tag can be repointed at other code. + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 + with: + persist-credentials: false + fetch-depth: 0 + + - name: tag matches VERSION + run: | + version=$(sed -n 's/^VERSION[[:space:]]*=[[:space:]]*//p' Makefile) + if [ "v$version" != "$GITHUB_REF_NAME" ]; then + echo "tag $GITHUB_REF_NAME does not match VERSION=$version" >&2 + exit 1 + fi + echo "VERSION=$version" >> "$GITHUB_ENV" + + - name: source archive + run: | + git archive --format=tar.gz --prefix="whoson-$VERSION/" \ + -o "whoson-$VERSION.tar.gz" "$GITHUB_SHA" + sha256sum "whoson-$VERSION.tar.gz" > "whoson-$VERSION.tar.gz.sha256" + + - name: release + env: + GH_TOKEN: ${{ github.token }} + run: | + gh release create "$GITHUB_REF_NAME" \ + --title "whoson $VERSION" \ + --generate-notes \ + "whoson-$VERSION.tar.gz" "whoson-$VERSION.tar.gz.sha256" diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..d1f92c6 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,21 @@ +# Changelog + +## 1.0.0 + +First release. + +- Lists TSO/E sessions from `DISPLAY TS,A` and SSH sessions from + `DISPLAY OMVS,A=ALL`, through the ZOAU shared library vector rather than a + shell call to `opercmd`: user, session type, status, address space id, pid, + job id, CPU time, elapsed time, service class, priority and region. +- `CPU` for an SSH session comes from `CT_SECS` on its own OMVS process; both + it and the TSO/E `CT` print as seconds.milliseconds. +- `PROCS` counts the processes below the session's pid, since each z/OS fork + gets its own address space. +- `USER` is the display's `USERID=`, which is not always the job name. +- Started tasks are dropped: the `sshd` listener process is recognised by its + parent being init, and its daemon account is left out. +- Output leaves with `write(2)` in the character set the destination expects, + and `--help` / `--version` / errors take the same path. +- Builds with IBM Open XL C/C++ 2.2 (clang 21.1), `-std=c17 -O3 -m64`, ASCII + character mode; `make list` writes a compiler listing. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..007f5de --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,50 @@ +# Contributing to whoson + +Small tool, small rules. + +## Building + +whoson is a single C17 file linked against the ZOAU shared library, so it +builds on z/OS and nowhere else: + +```sh +make # -> ./whoson +make check # under the CEE heap checker and storage report +make install # -> ~/.local/bin/whoson +``` + +Needs IBM Open XL C/C++ (`ibm-clang`, pinned by absolute path in the +`Makefile`), ZOAU 1.3 or later, and `LIBPATH` containing +`/usr/lpp/IBM/zoautil/lib`. + +GNU make and IBM's make both have to parse the Makefile: keep it to POSIX make +syntax (`?=` is out), and let `make -n` stay free of side effects. + +## Style + +- Warnings are bugs. The tree builds with `-Wall -Wextra -Wpedantic -Wshadow + -Wconversion`; a warning from any of them, or from `clang-tidy` with + `.clang-tidy`, gets fixed rather than silenced. +- `clang-format -i whoson.c` before committing; `.clang-format` is the + authority, and CI checks the result against clang-format 23.1.5. +- Comments say why, not what, and the file header says what the two displays + give and what they do not. + +## Changes + +- One PR per change, branched from `main`, merged through the PR. +- Touching how a display is parsed means saying which field was wrong and what + the console showed. Do not adjust a test or an example to make a claim true. +- No binaries in the tree, and nothing generated (`.clangd` indexes, + `whoson.json`) gets committed. + +## Releasing + +1. Bump `VERSION` in the `Makefile` and add the entry to `CHANGELOG.md`. +2. Merge, then tag `main` with `v<version>` and push the tag. +3. `.github/workflows/release.yml` refuses a tag that disagrees with + `VERSION`, builds the source archive, attaches it with its sha256, and + writes the notes. + +There is no binary in a release: it links the ZOAU 64-bit DLL and only builds +on z/OS, so a release ships the sources and the build instructions. @@ -34,11 +34,14 @@ ZOAU_HOME = /usr/lpp/IBM/zoautil PREFIX = $(HOME)/.local BINDIR = $(PREFIX)/bin +# The release workflow refuses a tag that does not match this, and the binary +# reports it through --version. +VERSION = 1.0.0 CCDIR = /usr/lpp/IBM/cnw/v2r2/openxl/bin CC = $(CCDIR)/ibm-clang LISTFMT = $(CCDIR)/ibm-clang-listing-formatter CPPFLAGS = -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=200809L -D_ALL_SOURCE \ - -D_EXT + -D_EXT -DWHOSON_VERSION=\"$(VERSION)\" CFLAGS = -std=c17 -O3 -m64 -fzos-le-char-mode=ascii -Wall -Wextra \ -Wpedantic -Wshadow -Wconversion -I$(ZOAU_HOME)/include ZOAU_DLL = $(ZOAU_HOME)/lib/zoautil.x @@ -1,5 +1,9 @@ # whoson +[](https://github.com/skurtz97/whoson/actions/workflows/ci.yml) +[](https://github.com/skurtz97/whoson/releases) +[](LICENSE) + Who is logged on to this z/OS system, and how: TSO/E or SSH, with the job id, CPU time, elapsed time, service class, priority, region size and process count. @@ -26,6 +30,12 @@ the POSIX work a TSO/E session has running. Each fork gets its own address space on z/OS, which is why the count follows the pid tree rather than the ASID. +```sh +whoson # the table +whoson --version # whoson 1.0.0 +whoson --help +``` + ## Requirements - z/OS with ZOAU installed at `/usr/lpp/IBM/zoautil` (v1.3 or later: the @@ -39,6 +49,19 @@ ASID. The build is 64-bit on purpose: the ZOAU shared library is a 64-bit DLL, so its sidedeck imports `CODE64`. +## Install + +Releases ship the sources, not a binary: whoson links the ZOAU 64-bit DLL and +only builds on z/OS. Unpack a release, build it, install it: + +```sh +gh release download --repo skurtz97/whoson --pattern 'whoson-*.tar.gz' +tar xzf whoson-*.tar.gz && cd whoson-*/ +make && make install +``` + +Or from a checkout, `make install` straight away. + ## Build and run ```sh @@ -96,6 +119,11 @@ so the console command is passed quoted (`"D TS,A"`) as a single argument. Unquoted, the `D` is read as an option letter and the call fails with `opercmd`'s usage text and rc 2. +## Contributing + +Build rules, style and the release steps are in `CONTRIBUTING.md`; what changed +in each release is in `CHANGELOG.md`. + ## License MIT OR Apache-2.0 OR BSD-2-Clause, at your option. See `LICENSE`. @@ -43,6 +43,11 @@ #define MAX_TOKENS 16 #define MAX_ARGS 64 + +/* Set by the Makefile from its VERSION, so the binary and the tag agree. */ +#ifndef WHOSON_VERSION +#define WHOSON_VERSION "unknown" +#endif #define MAX_PROCS 8192 #define MAX_ROWS 256 #define NAME_LEN 16 @@ -86,12 +91,13 @@ struct row { }; static const char usage_text[] = - "usage: whoson\n" + "usage: whoson [--help | --version]\n" "\n" "List logged-on users with session type (TSO/E or SSH).\n" "\n" "Options:\n" - " -h, --help show this help and exit\n"; + " -h, --help show this help and exit\n" + " -V, --version show the version and exit\n"; /* Write a message in the character set its destination expects. CEE converts * stdio output from ASCII to EBCDIC when the stream is a terminal, and sshd @@ -530,6 +536,10 @@ int main(int argc, char *argv[]) { emit_str(STDOUT_FILENO, usage_text); return 0; } + if (strcmp(argv[1], "-V") == 0 || strcmp(argv[1], "--version") == 0) { + emit_str(STDOUT_FILENO, "whoson " WHOSON_VERSION "\n"); + return 0; + } return usage_error("unknown argument"); } |
