/*************************************************************************
* This program is copyright (C) 1985, 1986 by Jonathan Payne. It is *
* provided to you without charge for use only on a licensed Unix *
* system. You may copy JOVE provided that this notice is included with *
* the copy. You may not sell copies of this program or versions *
* modified for use on microcomputer systems, unless the copies are *
* included with a Unix system distribution and the source is provided. *
*************************************************************************/
# include "iproc-pipes.c"
int killem
= -1; /* -1 means undetermined */
for (p
= procs
; p
!= 0; p
= p
->p_next
)
yorn
= ask("y", "Should I kill your i-processes? ");
killem
= (Upper(*yorn
) == 'Y');
for (p
= procs
; p
!= 0; p
= p
->p_next
)
if (strcmp(proc_buf(p
), name
) == 0) {
for (p
= procs
; p
!= 0; p
= p
->p_next
)
if (p
->p_buffer
== curbuf
) {
for (p
= procs
; p
!= 0; p
= p
->p_next
)
if (p
->p_buffer
== b
&& !p
->p_eof
)
complain("[There is a process tied to %s]", proc_buf(p
));
/* Process receive: receives the characters in buf, and appends them to
the buffer associated with p. */
if (curwind
->w_bufp
== p
->p_buffer
)
w
= windbp(p
->p_buffer
); /* Is this window visible? */
do_disp
= (in_window(w
, p
->p_mark
->m_line
) != -1);
savepoint
= MakeMark(curline
, curchar
, FLOATER
);
ToMark(p
->p_mark
); /* Where output last stopped. */
if (savepoint
->m_line
== curline
&& savepoint
->m_char
== curchar
)
MarkSet(p
->p_mark
, curline
, curchar
);
ToMark(savepoint
); /* Back to where we were. */
if (p
== 0 || p
->p_state
== DEAD
)
if (killpg(p
->p_pid
, sig
) == -1)
s_mess("Cannot kill %s!", proc_buf(p
));
/* Deal with a process' death. proc_rec turns on the FREEUP bit when it
it gets the "EOF" from portsrv. FREEUP'd processes get unlinked from
the list, and the proc stucture and proc_buf(p) get free'd up, here. */
for (p
= procs
; p
!= 0; p
= next
) {
cur_proc
= next
? next
: prev
;
free((char *) p
->p_name
);
char *fmt
= "%-15s %-15s %-8s %s",
message("[No subprocesses]");
TOstart("Process list", TRUE
);
Typeout(fmt
, "Buffer", "Status", "Pid ", "Command");
Typeout(fmt
, "------", "------", "--- ", "-------");
for (p
= procs
; p
!= 0; p
= p
->p_next
) {
sprintf(pidstr
, "%d", p
->p_pid
);
Typeout(fmt
, proc_buf(p
), pstate(p
), pidstr
, p
->p_name
);
do_rtp(cur_proc
->p_mark
);
MarkSet(cur_proc
->p_mark
, curline
, curchar
);
while (LookingAt(proc_prompt
, linebuf
, curchar
))
SetDot(dosearch(proc_prompt
, 1, 1));
strcpy(genbuf
, linebuf
+ curchar
);
sprintf(shell
, "shell-%d", number
++);
while (proc_exists(shell
));
proc_strt(shell
, "i-shell", Shell
, basename(Shell
), "-i", 0);
SetWind(windlook(shell
));
extern char ShcomBuf
[100],
command
= ask(ShcomBuf
, ProcFmt
);
null_ncpy(ShcomBuf
, command
, (sizeof ShcomBuf
) - 1);
proc_strt(MakeName(command
), command
, Shell
, basename(Shell
), ShFlags
, command
, 0);
pid
= wait2(&w
.w_status
, (WNOHANG
| WUNTRACED
));
pid
= wait3(&w
, (WNOHANG
| WUNTRACED
), (struct rusage
*) 0);
if ((child
= proc_pid(pid
)) == 0)
child
->p_state
= STOPPED
;
child
->p_howdied
= EXITED
;
else if (WIFSIGNALED(w
)) {
child
->p_reason
= w
.w_termsig
;
child
->p_howdied
= KILLED
;
s_mess("%s [%s] %s", pstate(child
), proc_buf(child
), proc_cmd(child
));
/* Push/pod process bindings. I openly acknowledge that this is a
kludge, but I can't be bothered making it right. */
struct proc_bind
*pb_next
;
struct proc_bind
*PBinds
= 0;
register struct proc_bind
*p
;
for (p
= PBinds
; p
!= 0; p
= p
->pb_next
)
p
->pb_map
[p
->pb_key
] = p
->pb_push
;
register struct proc_bind
*p
;
for (p
= PBinds
; p
!= 0; p
= p
->pb_next
) {
p
->pb_push
= p
->pb_map
[p
->pb_key
];
p
->pb_map
[p
->pb_key
] = p
->pb_cmd
;
if ((d
= findcom(ProcFmt
, NOTHING
)) == 0)
s_mess(": %f %s ", d
->Name
);
ProcB2(map
, lastkey
, cmd
)
register struct proc_bind
*p
;
complain("[Empty key sequence]");
complain("[Unexpected end-of-line]");
if (nextmap
= IsPrefix(map
[c
]))
if (curbuf
->b_type
== B_IPROCESS
)
for (p
= PBinds
; p
!= 0; p
= p
->pb_next
)
if (p
->pb_key
== c
&& p
->pb_map
== map
)
p
= (struct proc_bind
*) emalloc(sizeof *p
);
if (curbuf
->b_type
== B_IPROCESS
)