aboutsummaryrefslogtreecommitdiff
path: root/sys/etc/proscmd.x
blob: cf1e5bb35f07eecff35fdb97c2ab925a189dca58 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

include	<config.h>

# PROSCMD -- Process an OS escape command from a subprocess.  Execute the
# command and return the exit status to the subprocess via IPC.

procedure proscmd (pr, cmd)

int	pr		# subprocess process slot number
char	cmd[ARB]	# host command to be executed

char	statbuf[5]
int	fd, status, op
int	itoc(), oscmd()
include	"prc.com"

begin
	fd = pr_outfd[pr]

	# Execute the command (waits for completion).
	status = oscmd (cmd, "", "", "")

	# Encode the return status.
	op = itoc (status, statbuf, 5) + 1
	statbuf[op] = '\n'
	statbuf[op+1] = EOS

	# Return the status to the subprocess.
	call write (fd, statbuf, op)
	call flush (fd)
end