File:  [Research Unix] / researchv10no / cmd / spitbol / osclose.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:21:35 2018 UTC (8 years, 1 month ago) by root
Branches: belllabs, MAIN
CVS tags: researchv10, HEAD
researchv10 Norman


/*
	osclose( ioptr ) closes the file represented by the ioblk.
	osclose will flush an output file's buffer before closing.
*/

#include "spitblks.h"
#include "spitio.h"

int
osclose( ioptr )

struct	ioblk	*ioptr;

{
	register int	errcnt = 0;

	if ( !(ioptr -> flg & IO_OPN))
		return 0;

	if ( ioptr -> flg & IO_OUP )
		errcnt += flush( ioptr );

	if ( ioptr -> flg & IO_SYS )
		return errcnt;

	if ( close( ioptr -> fdn ) < 0)
		errcnt++;
	ioptr -> flg &= ~IO_OPN;

	if ( ioptr -> flg & IO_PIP ) {
		if ( ioptr -> flg & IO_DED )
			ioptr -> flg &= ~IO_DED;
		else if ( ioptr -> flg & IO_INP ) {
			kill( ioptr -> pid );
			oswait( ioptr -> pid);
		} else oswait( ioptr -> pid );
	}

	return errcnt;
}


unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.