17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 77c478bd9Sstevel@tonic-gate * with the License. 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate * and limitations under the License. 137c478bd9Sstevel@tonic-gate * 147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * CDDL HEADER END 217c478bd9Sstevel@tonic-gate */ 22*965005c8Schin 23*965005c8Schin /* 24*965005c8Schin * Copyright 1990 Sun Microsystems, Inc. All rights reserved. 25*965005c8Schin * Use is subject to license terms. 26*965005c8Schin */ 27*965005c8Schin 287c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 297c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate 32*965005c8Schin #pragma ident "%Z%%M% %I% %E% SMI" 337c478bd9Sstevel@tonic-gate /* 347c478bd9Sstevel@tonic-gate * UNIX shell 357c478bd9Sstevel@tonic-gate */ 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate #include "defs.h" 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate /* ======== error handling ======== */ 417c478bd9Sstevel@tonic-gate 42*965005c8Schin void 43*965005c8Schin failed(unsigned char *s1, const char *s2) 447c478bd9Sstevel@tonic-gate { 457c478bd9Sstevel@tonic-gate prp(); 467c478bd9Sstevel@tonic-gate prs_cntl(s1); 47*965005c8Schin if (s2) { 487c478bd9Sstevel@tonic-gate prs(colon); 49*965005c8Schin prs((unsigned char *)s2); 507c478bd9Sstevel@tonic-gate } 517c478bd9Sstevel@tonic-gate newline(); 527c478bd9Sstevel@tonic-gate exitsh(ERROR); 537c478bd9Sstevel@tonic-gate } 547c478bd9Sstevel@tonic-gate 55*965005c8Schin void 56*965005c8Schin error(unsigned char *s) 577c478bd9Sstevel@tonic-gate { 58*965005c8Schin failed(s, (const char *)NIL); 597c478bd9Sstevel@tonic-gate } 607c478bd9Sstevel@tonic-gate 61*965005c8Schin void 62*965005c8Schin exitsh(int xno) 637c478bd9Sstevel@tonic-gate { 647c478bd9Sstevel@tonic-gate /* 657c478bd9Sstevel@tonic-gate * Arrive here from `FATAL' errors 667c478bd9Sstevel@tonic-gate * a) exit command, 677c478bd9Sstevel@tonic-gate * b) default trap, 687c478bd9Sstevel@tonic-gate * c) fault with no trap set. 697c478bd9Sstevel@tonic-gate * 707c478bd9Sstevel@tonic-gate * Action is to return to command level or exit. 717c478bd9Sstevel@tonic-gate */ 727c478bd9Sstevel@tonic-gate exitval = xno; 737c478bd9Sstevel@tonic-gate flags |= eflag; 747c478bd9Sstevel@tonic-gate if ((flags & (forcexit | forked | errflg | ttyflg)) != ttyflg) 757c478bd9Sstevel@tonic-gate done(0); 767c478bd9Sstevel@tonic-gate else 777c478bd9Sstevel@tonic-gate { 787c478bd9Sstevel@tonic-gate clearup(); 797c478bd9Sstevel@tonic-gate restore(0); 807c478bd9Sstevel@tonic-gate (void) setb(1); 817c478bd9Sstevel@tonic-gate execbrk = breakcnt = funcnt = 0; 827c478bd9Sstevel@tonic-gate longjmp(errshell, 1); 837c478bd9Sstevel@tonic-gate } 847c478bd9Sstevel@tonic-gate } 857c478bd9Sstevel@tonic-gate 86*965005c8Schin void 87*965005c8Schin rmtemp(struct ionod *base) 887c478bd9Sstevel@tonic-gate { 89*965005c8Schin while (iotemp > base) { 907c478bd9Sstevel@tonic-gate unlink(iotemp->ioname); 917c478bd9Sstevel@tonic-gate free(iotemp->iolink); 927c478bd9Sstevel@tonic-gate iotemp = iotemp->iolst; 937c478bd9Sstevel@tonic-gate } 947c478bd9Sstevel@tonic-gate } 957c478bd9Sstevel@tonic-gate 96*965005c8Schin void 97*965005c8Schin rmfunctmp(void) 987c478bd9Sstevel@tonic-gate { 99*965005c8Schin while (fiotemp) { 1007c478bd9Sstevel@tonic-gate unlink(fiotemp->ioname); 1017c478bd9Sstevel@tonic-gate fiotemp = fiotemp->iolst; 1027c478bd9Sstevel@tonic-gate } 1037c478bd9Sstevel@tonic-gate } 1047c478bd9Sstevel@tonic-gate 105*965005c8Schin void 106*965005c8Schin failure(unsigned char *s1, unsigned char *s2) 1077c478bd9Sstevel@tonic-gate { 1087c478bd9Sstevel@tonic-gate prp(); 1097c478bd9Sstevel@tonic-gate prs_cntl(s1); 110*965005c8Schin if (s2) { 1117c478bd9Sstevel@tonic-gate prs(colon); 1127c478bd9Sstevel@tonic-gate prs(s2); 1137c478bd9Sstevel@tonic-gate } 1147c478bd9Sstevel@tonic-gate newline(); 1157c478bd9Sstevel@tonic-gate 1167c478bd9Sstevel@tonic-gate if (flags & errflg) 1177c478bd9Sstevel@tonic-gate exitsh(ERROR); 1187c478bd9Sstevel@tonic-gate 1197c478bd9Sstevel@tonic-gate flags |= eflag; 1207c478bd9Sstevel@tonic-gate exitval = ERROR; 1217c478bd9Sstevel@tonic-gate exitset(); 1227c478bd9Sstevel@tonic-gate } 123