PiDP-8/I SoftwareCheck-in [dd5ad30192]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Added the SCREEN_MANAGER=dtach option
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | screen-mgr-none-dtach
Files: files | file ages | folders
SHA3-256: dd5ad30192ae48e5343f9621b806c6aceea636f20042b8b9312f86703064194f
User & Date: tangent 2020-01-26 21:32:49
Context
2020-01-26
21:33
Tweaked a potentially confusing message output from "pidp8i stop". check-in: d044732095 user: tangent tags: screen-mgr-none-dtach
21:32
Added the SCREEN_MANAGER=dtach option check-in: dd5ad30192 user: tangent tags: screen-mgr-none-dtach
20:53
Added the SCREEN_MANAGER=none feature, being an alternative to "make run" for running the simulator hard-attached to the local terminal while still making use of the media in the install tree, rather than the pristine pre-install versions. check-in: b6e58203de user: tangent tags: screen-mgr-none-dtach
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to README.md.

753
754
755
756
757
758
759
760
761
762
763
764














765
766
767
768
769
770
771
772
we’d have to export the console [another way][scons] or you’d have to
fire it up interactively any time you wanted to use it. This scheme lets
us have it both ways.

The `SCREEN_MANAGER` setting is for use by those that need something
other than GNU `screen`. There are several alternatives:

*   **`screen`**: the default, per above

*   [**`tmux`**][tmux]: a popular alternative to `screen`, especially on
    BSD platforms















*   **`none`**: effectively aliases the `pidp8i` and `pidp8i start`
    commands, attaching the simulator to the local console. The `pidp8i
    stop` command becomes a no-op, since stopping the simulator is then
    done in the standard SIMH way: <kbd>Ctrl-E, quit</kbd>.

Note that the alternative screen managers are not installed by default.
If you set `SCREEN_MANAGER=tmux`, you must then ensure that `tmux` is in
fact installed before the `pidp8i` script goes to try and use it. On







|

|


>
>
>
>
>
>
>
>
>
>
>
>
>
>
|







753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
we’d have to export the console [another way][scons] or you’d have to
fire it up interactively any time you wanted to use it. This scheme lets
us have it both ways.

The `SCREEN_MANAGER` setting is for use by those that need something
other than GNU `screen`. There are several alternatives:

*   **`screen`**: The default, per above

*   [**`tmux`**][tmux]: A popular alternative to `screen`, especially on
    BSD platforms

*   [**`dtach`**][dtach]: A minimalist alternative to `screen` which
    handles only the terminal attach/detach features.

    In addition to the virtues called out on the program’s home page,
    this option has a side benefit for some PiDP-8/I users: `screen` and
    `tmux` assume an ANSI X3.64 terminal (e.g. DEC VT102 or xterm),
    because they interpret escape codes to provide features such as
    their scrollback buffer. It is somewhat rare to use the PiDP-8/I
    with an ANSI terminal as the PDP-8 predates that standard by many
    years, so a lot of the software for those systems assumes either a
    dumb teletypewriter or some other terminal type, such as a Tek 4010
    series. In the latter case, these ANSI screen managers can get in
    the way and mess things up. Thus this option.

*   **`none`**: Effectively aliases the `pidp8i` and `pidp8i start`
    commands, attaching the simulator to the local console. The `pidp8i
    stop` command becomes a no-op, since stopping the simulator is then
    done in the standard SIMH way: <kbd>Ctrl-E, quit</kbd>.

Note that the alternative screen managers are not installed by default.
If you set `SCREEN_MANAGER=tmux`, you must then ensure that `tmux` is in
fact installed before the `pidp8i` script goes to try and use it. On

Changes to bin/pidp8i.in.

32
33
34
35
36
37
38

39
40
41
42
43
44
45
..
46
47
48
49
50
51
52



53
54
55
56
57
58
59
60
61
62
63
64
65



66
67
68
69
70
71
72
..
77
78
79
80
81
82
83



84
85
86
87
88
89
90
...
160
161
162
163
164
165
166



167
168
169
170
171
172
173
...
201
202
203
204
205
206
207



208
209
210
211
212
213
214
215
216
217

bootdir="@BOOTDIR@"
prefix="@ABSPREFIX@"
sim="$prefix/bin/pidp8i-sim"
scanswitch="$prefix/libexec/scanswitch"
systemctl=$(uname -r | grep -qw Microsoft && echo /bin/nothing || echo /bin/systemctl)
ggrep=$(which ggrep grep 2> /dev/null | head -1)


if [ -e "$prefix/etc/pidp8i.rc" ]
then
    . "$prefix/etc/pidp8i.rc"
fi
[ -n "$SCREEN_MANAGER" ] || SCREEN_MANAGER=screen

................................................................................
is_running() {
    if [ "$SCREEN_MANAGER" = "none" ]
    then
        return 1
    elif [ "$SCREEN_MANAGER" = "tmux" ]
    then
        tmux has-session -t pidp8i 2>/dev/null



    else
        procs=`screen -list pidp8i | $ggrep -Pc '\d\.pidp8i'`
        test -n "$procs" && test $procs -gt 0 && return 0 || return 1
    fi
}

sim_child_pid() {
    if [ "$SCREEN_MANAGER" = "none" ]
    then
        echo ""
    elif [ "$SCREEN_MANAGER" = "tmux" ]
    then
        tmux list-sessions -F '#{session_name} #{pid}' | awk '/^pidp8i / {print $2}'



    else
        screen -ls pidp8i | grep -Eo '[[:digit:]]+\.pidp8i' | grep -Eo '^[[:digit:]]+'
    fi
}

# Were we given a command line argument?
if [ -z "$1" ]
................................................................................
        exec $0 start
    elif is_running
    then
        echo Joining simulator session already in progress...
        if [ "$SCREEN_MANAGER" = "tmux" ]
        then
            exec tmux attach-session -d -t pidp8i



        else
            exec screen -r -S pidp8i
        fi
    else
        cat <<ERROR
Either the simulator isn't running, or it isn't running under a ${SCREEN_MANAGER}
session owned by @INSTUSR@.  Did you start the simulator via systemd?
................................................................................
    # Start the simulator
    if [ "$SCREEN_MANAGER" = "none" ]
    then
        exec "$sim" "$bscript"
    elif [ "$SCREEN_MANAGER" = "tmux" ]
    then
        tmux new-session -s pidp8i -d "$sim" "$bscript"



    else
        screen -dm -S pidp8i "$sim" "$bscript"
    fi

    # Tell systemd where to find the backgrounded simulator so it can
    # stop it via systemctl.  Skipped on non-systemd systems and where
    # SCREEN_MANAGER=none.
................................................................................
            # only child dying.  Nuke it hard if so.
            if ! is_running || [ "$SCREEN_MANAGER" = "none" ]
            then
                echo "The PiDP-8/I simulator is not running."
            elif [ "$SCREEN_MANAGER" = "tmux" ]
            then
                tmux kill-session -t pidp8i



            else
                screen -S pidp8i -X quit
            fi

            exit 0
        fi
    done 

    exit 1
fi







>







 







>
>
>













>
>
>







 







>
>
>







 







>
>
>







 







>
>
>










32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
..
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
..
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
...
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
...
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233

bootdir="@BOOTDIR@"
prefix="@ABSPREFIX@"
sim="$prefix/bin/pidp8i-sim"
scanswitch="$prefix/libexec/scanswitch"
systemctl=$(uname -r | grep -qw Microsoft && echo /bin/nothing || echo /bin/systemctl)
ggrep=$(which ggrep grep 2> /dev/null | head -1)
dtsock=/tmp/pidp8i-dtach.sock

if [ -e "$prefix/etc/pidp8i.rc" ]
then
    . "$prefix/etc/pidp8i.rc"
fi
[ -n "$SCREEN_MANAGER" ] || SCREEN_MANAGER=screen

................................................................................
is_running() {
    if [ "$SCREEN_MANAGER" = "none" ]
    then
        return 1
    elif [ "$SCREEN_MANAGER" = "tmux" ]
    then
        tmux has-session -t pidp8i 2>/dev/null
    elif [ "$SCREEN_MANAGER" = "dtach" ]
    then
        test -e $dtsock
    else
        procs=`screen -list pidp8i | $ggrep -Pc '\d\.pidp8i'`
        test -n "$procs" && test $procs -gt 0 && return 0 || return 1
    fi
}

sim_child_pid() {
    if [ "$SCREEN_MANAGER" = "none" ]
    then
        echo ""
    elif [ "$SCREEN_MANAGER" = "tmux" ]
    then
        tmux list-sessions -F '#{session_name} #{pid}' | awk '/^pidp8i / {print $2}'
    elif [ "$SCREEN_MANAGER" = "dtach" ]
    then
        test -e $dtsock && fuser -f $dtsock | cut -f2 -d:
    else
        screen -ls pidp8i | grep -Eo '[[:digit:]]+\.pidp8i' | grep -Eo '^[[:digit:]]+'
    fi
}

# Were we given a command line argument?
if [ -z "$1" ]
................................................................................
        exec $0 start
    elif is_running
    then
        echo Joining simulator session already in progress...
        if [ "$SCREEN_MANAGER" = "tmux" ]
        then
            exec tmux attach-session -d -t pidp8i
        elif [ "$SCREEN_MANAGER" = "dtach" ]
        then
            exec dtach -a $dtsock
        else
            exec screen -r -S pidp8i
        fi
    else
        cat <<ERROR
Either the simulator isn't running, or it isn't running under a ${SCREEN_MANAGER}
session owned by @INSTUSR@.  Did you start the simulator via systemd?
................................................................................
    # Start the simulator
    if [ "$SCREEN_MANAGER" = "none" ]
    then
        exec "$sim" "$bscript"
    elif [ "$SCREEN_MANAGER" = "tmux" ]
    then
        tmux new-session -s pidp8i -d "$sim" "$bscript"
    elif [ "$SCREEN_MANAGER" = "dtach" ]
    then
        dtach -A $dtsock -Ez "$sim" "$bscript"
    else
        screen -dm -S pidp8i "$sim" "$bscript"
    fi

    # Tell systemd where to find the backgrounded simulator so it can
    # stop it via systemctl.  Skipped on non-systemd systems and where
    # SCREEN_MANAGER=none.
................................................................................
            # only child dying.  Nuke it hard if so.
            if ! is_running || [ "$SCREEN_MANAGER" = "none" ]
            then
                echo "The PiDP-8/I simulator is not running."
            elif [ "$SCREEN_MANAGER" = "tmux" ]
            then
                tmux kill-session -t pidp8i
            elif [ "$SCREEN_MANAGER" = "dtach" ]
            then
                kill $(sim_child_pid)
            else
                screen -S pidp8i -X quit
            fi

            exit 0
        fi
    done 

    exit 1
fi