Debian Codegraph @

gui/GraphLib/libsrc/uimxR5/src/subproc.c

raw
1 /*---------------------------------------------------------------------
2 * $Date: 2009-08-18 15:23:20 $ $Revision: 1.2 $
3 *---------------------------------------------------------------------
4 * Copyright (c) 1992, Visual Edge Software Ltd.
5 *
6 * ALL RIGHTS RESERVED. Permission to use, copy, modify, and
7 * distribute this software and its documentation for any purpose
8 * and without fee is hereby granted, provided that the above
9 * copyright notice appear in all copies and that both that
10 * copyright notice and this permission notice appear in supporting
11 * documentation, and that the name of Visual Edge Software not be
12 * used in advertising or publicity pertaining to distribution of
13 * the software without specific, written prior permission. The year
14 * included in the notice is the year of the creation of the work.
15 *---------------------------------------------------------------------
16 * File_Description_Section
17 *--------------------------------------------------------------------*/
18 /*
19 .VERSION
20 090813 last modif KB
21 */
22
23
24 /*--- include files ---*/
25 #include <unistd.h>
26
27 #include "uxproto.h"
28 #include "version.h"
29 #include "subproc.h"
30 #include "sp_spmd.h"
31 #include "sp_pty.h"
32
33 /*--- macro symbolic constants ---*/
34
35 /*--- macro functions ---*/
36
37 /*--- types ---*/
38
39 /*--- external functions ---*/
40
41 extern void UxTextAppend();
42
43
44 /*--- external variables ---*/
45
46 /*--- global variables ---*/
47 SubprocInfo_t *UxSpArray[MAX_SUBPROC];
48 SubprocMgr_t UxSubprocMgr;
49
50 /*--- file global variables ---*/
51 M_FILE_VERSION("$Header")
52
53 /*--- forward declaration of static functions ---*/
54
55
56 /*----------------------------------------------------------------------
57 * NAME: <int UxSetSubprocExitCallback(index)>
58 * DESCRIPTION: <Set the exit callback function for the process>
59 * PARAMETERS: handle h - handle to subproc
60 * void (*fnt)() - exit callback function
61 * RETURN: ERROR or NO_ERROR
62 * EXT REFS: UxSpArray
63 * EXT EFFECTS: UxSpArray
64 * ASSUMPTIONS:
65 * REVISIONS: 05/01/93 fix3810 clean-up
66 dd/mm/yy fix# fix_description
67 *--------------------------------------------------------------------*/
68 int UxSetSubprocExitCallback(h, fnt)
69 handle h;
70 void (*fnt)();
71 {
72 SubprocInfo_t *sp;
73
74 if(UxCheckIndex(h) == ERROR)
75 return(ERROR);
76
77 sp = UxSpArray[h];
78 sp->exit_cb = fnt;
79 return(NO_ERROR);
80 }
81
82 /*----------------------------------------------------------------------
83 * NAME: <int UxDeleteSubproc(index)>
84 * DESCRIPTION: <Delete the structure and set the entry to 0>
85 * PARAMETERS: handle index - index into array of subprocs
86 * RETURN: ERROR or NO_ERROR
87 * EXT REFS: UxSpArray
88 * EXT EFFECTS: UxSpArray
89 * ASSUMPTIONS:
90 * REVISIONS: 05/01/93 fix3810 clean-up
91 02/04/93 fix4074 don't execute if subproc exiting
92 dd/mm/yy fix# fix_description
93 *--------------------------------------------------------------------*/
94 int UxDeleteSubproc(index)
95 handle index;
96 {
97
98 if (UxSpArray[index] == (SubprocInfo_t *) 0) {
99 return ERROR;
100 }
101
102 if (UxSpArray[index]->subprocStatus != EXITING) {
103
104 if (UxCheckIndex(index) == ERROR) {
105 return ERROR;
106 }
107
108 /* Exit the process if running and close tty/pty
109 * remove the XInput fd */
110 UxExitSubproc(index);
111
112 if(UxSpArray[index]->process)
113 UxFree(UxSpArray[index]->process);
114
115 if(UxSpArray[index]->defarg)
116 UxFree(UxSpArray[index]->defarg);
117
118 UxFree(UxSpArray[index]);
119 UxSpArray[index] = (SubprocInfo_t *) 0;
120 } else {
121 error_msg(CGETS(MS_MISC1_PROCESS_EXITING,
122 DS_MS_MISC1_PROCESS_EXITING));
123 }
124 return NO_ERROR;
125 }
126 /*----------------------------------------------------------------------
127 * NAME: <int UxDelayedDeleteSubproc(index)>
128 * DESCRIPTION: <Delayed delete of the subproc>
129 * PARAMETERS: handle thisHandle - index into array of subprocs
130 * RETURN: void
131 * EXT REFS:
132 * EXT EFFECTS:
133 * ASSUMPTIONS:
134 * REVISIONS: 29/04/93 - created
135 dd/mm/yy fix# fix_description
136 *--------------------------------------------------------------------*/
137 int UxDelayedDeleteSubproc (thisHandle)
138 handle thisHandle;
139 {
140 static handle lastHandle = -1;
141
142 /*-----------------------------------------------------
143 * Safety check. Allow a value of -1 for handles. It'll
144 * be used to force the previous delete.
145 *-----------------------------------------------------*/
146
147 if ((thisHandle != -1) &&
148 (UxCheckIndex (thisHandle) == ERROR)) {
149 return(ERROR);
150 }
151
152 /*-----------------------------------------------------
153 * If we're already in a DELAYED_EXIT, just return
154 * Otherwise, the next time UxDelayedDeleteSubproc is
155 * called it'll try to delete an already deleted handle.
156 *-----------------------------------------------------*/
157 if ((thisHandle == -1) ||
158 (UxSpArray[thisHandle]->subprocStatus != DELAYED_EXIT)) {
159
160 /*-----------------------------------------------------
161 * The user might have called UxDeleteSubproc after
162 * calling UxDelayedDeleteSubproc on the same handle.
163 * In that case, UxSpArray[lastHandle] is NULL.
164 *-----------------------------------------------------*/
165 if (lastHandle != -1) {
166 UxDeleteSubproc (lastHandle);
167 }
168
169 lastHandle = thisHandle;
170 if (thisHandle != -1) {
171 UxSpArray[thisHandle]->subprocStatus = DELAYED_EXIT;
172 }
173 }
174 return NO_ERROR;
175 }
176
177 /*----------------------------------------------------------------------
178 * NAME: <handle UxCreateSubproc(process, defarg, fnt)>
179 * DESCRIPTION: <creates a subprocess entry and returns a handle to it>
180 * PARAMETERS: char *process - subprocess to be created
181 *defarg - default argument to the
182 subprocess - overridden by
183 argument passed to UxRunSubproc
184 void (*fnt)() - output function caused when
185 output present from subproc
186 * RETURN: subprocess handle = index into subproc arrray
187 * EXT REFS: UxSpArray
188 * EXT EFFECTS: UxSpArray
189 * ASSUMPTIONS:
190 * REVISIONS: 05/01/93 fix3810 clean-up
191 dd/mm/yy fix# fix_description
192 *--------------------------------------------------------------------*/
193 handle UxCreateSubproc(process, defarg, fnt)
194 char *process, *defarg;
195 void (*fnt)();
196 {
197 SubprocInfo_t *sp;
198 int index, i;
199 static int initialized = 0;
200 int putenv();
201
202
203 if (!process || !*process)
204 {
205 UxInternalError( __FILE__, __LINE__,
206 CGETS( MS_MISC1_NULL_PROC_ERR, DS_MS_MISC1_NULL_PROC_ERR));
207 return ERROR;
208 }
209
210 if(!initialized)
211 {
212 for(i = 0; i < MAX_SUBPROC; i++) {
213 UxSpArray[i] = (SubprocInfo_t *)0;
214 }
215 putenv("TERM=uimx");
216 initialized = 1;
217 }
218
219 if( (index = UxGetSp()) == ERROR)
220 return ERROR;
221
222 sp = UxSpArray[index];
223
224 if(! (sp->process = UxMalloc(strlen(process) + 1)) )
225 {
226 UxInternalError( __FILE__, __LINE__,
227 CGETS( MS_MISC_MALLOC_ERR, DS_MS_MISC_MALLOC_ERR));
228 UxFree( (char *) sp);
229 UxSpArray[index] = (SubprocInfo_t *)0;
230 return ERROR;
231 }
232 strcpy(sp->process, process);
233
234 if(!defarg || (defarg[0] == '\0'))
235 sp->defarg = (char *)0;
236 else if(! (sp->defarg = UxMalloc(strlen(defarg) + 1)) )
237 {
238 UxInternalError( __FILE__, __LINE__,
239 CGETS( MS_MISC_MALLOC_ERR, DS_MS_MISC_MALLOC_ERR));
240 UxFree(sp->process);
241 UxFree( (char *) sp);
242 UxSpArray[index] = (SubprocInfo_t *)0;
243 return ERROR;
244 }
245
246 if(defarg && (defarg[0] != '\0'))
247 strcpy(sp->defarg, defarg);
248
249 sp->output_fnt = fnt;
250 sp->exit_cb = 0;
251 sp->echo= 0;
252
253 #ifdef DEBUG
254 fprintf(stderr, ">>(%d) [UxCreateSubproc] handle=%d\n", getpid(),
255 index);
256 #endif /* DEBUG */
257
258 return(index);
259 }
260
261 /*----------------------------------------------------------------------
262 * NAME: <int UxSetSubprocEcho(sp_h, echo)>
263 * DESCRIPTION: <Set the echo field for the process>
264 * PARAMETERS: handle sp_h - process handle
265 int echo - do we want echo ?
266 * RETURN: ERROR/NO_ERROR
267 * EXT REFS: UxSpArray
268 * EXT EFFECTS: UxSpArray
269 * ASSUMPTIONS:
270 * REVISIONS: 05/01/93 fix3810 clean-up
271 dd/mm/yy fix# fix_description
272 *--------------------------------------------------------------------*/
273 int UxSetSubprocEcho(sp_h, echo)
274 handle sp_h;
275 int echo;
276 {
277 SubprocInfo_t *sp;
278
279 if(UxCheckIndex(sp_h) == ERROR)
280 return(ERROR);
281
282 sp = UxSpArray[sp_h];
283
284 sp->echo= echo;
285 return NO_ERROR;
286 }
287
288
289 /*----------------------------------------------------------------------
290 * NAME: <UxMarkFileCloseOnExec (flag)>
291 * DESCRIPTION: <This function marks all the file descriptors above 2
292 to be closed for the child proc after 'exec' calls.
293
294 This is used before running any standard scripts via system(),
295 or subprocesses which involve pipes.
296
297 Otherwise things start hanging if the child process
298 cannot 'exec' properly, leading to wierd states on the X
299 connection, and the pipes themselves.>
300 * PARAMETERS: int flag -close-on-exec flag
301 * RETURN: NONE
302 * EXT REFS: globals_used
303 * EXT EFFECTS: globals or other things altered
304 * ASSUMPTIONS:
305 * REVISIONS: 14/11/91 creation
306 04/01/92 fix3384
307 05/01/93 fix3810 cleanup
308 07/07/93 fix4339 dg port
309 dd/mm/yy fix# fix_description
310 *--------------------------------------------------------------------*/
311 void UxMarkFileCloseOnExec(flag)
312 int flag;
313 {
314 int i;
315
316 /* For dg88, we do not want the SYSV code because in design time uimx hangs
317 and we have to do Ctrl-C to unhang it.
318 It works fine with the 'else' code.
319 */
320 #if defined(SYSV) && !defined(dg88)
321 for (i = 3; i < _NFILE; i++)
322 (void) fcntl(i, F_SETFD, flag);
323 #else /* SYSV */
324 for (i = getdtablesize(); i > 2; i--)
325 (void) fcntl(i, F_SETFD, flag);
326 #endif /* SYSV */
327 }
328
329
330 /*----------------------------------------------------------------------
331 * NAME: <int UxRunSubproc(sp_vh, cmd_line)>
332 * DESCRIPTION: <Looks up the object and start the subprocess.>
333 * PARAMETERS: handle sp_vh -- handle indicating the process
334 char *cmd_line -- arguments to the process
335 * RETURN: ERROR / NO_ERROR
336 * EXT REFS: UxSpArray
337 * EXT EFFECTS: globals or other things altered
338 * ASSUMPTIONS:
339 * REVISIONS: 05/01/93 fix3810 clean-up
340 dd/mm/yy fix# fix_description
341 *--------------------------------------------------------------------*/
342 int UxRunSubproc(sp_vh, cmd_line)
343 handle sp_vh;
344 char *cmd_line;
345 {
346 char *cmd;
347 SubprocInfo_t *sp;
348
349 if(UxCheckIndex(sp_vh) == ERROR) {
350 return(ERROR);
351 }
352
353 if (UxSpArray[sp_vh]->subprocStatus == DELAYED_EXIT) {
354 UxError( CGETS( MS_MISC_HNDL_DELAYED_EXIT,
355 DS_MS_MISC_HNDL_DELAYED_EXIT));
356 return(ERROR);
357 }
358
359 sp = UxSpArray[sp_vh];
360
361 if(sp->pid > 0) {
362 error_msg(CGETS( MS_MISC_SUBPROC_RUNNIN,
363 DS_MS_MISC_SUBPROC_RUNNIN));
364 return(ERROR);
365 }
366
367 if(cmd_line && (cmd_line[0] != '\0'))
368 cmd = cmd_line;
369 else
370 cmd = sp->defarg;
371
372 if (UxExecSubprocess(sp, cmd) == ERROR) {
373 return(ERROR);
374 }
375
376 return(NO_ERROR);
377 }
378
379 /*----------------------------------------------------------------------
380 * NAME: <int UxExecSubproc(sp_vh, cmd_line)>
381 * DESCRIPTION: <Looks up the object and start the subprocess
382 Same as UxRunSubproc, but kill the process if it is
383 still running. Main purpose is for processes
384 that die after execution e.g. "ls".>
385 * PARAMETERS: handle sp_vh -- handle indicating the process
386 char *cmd_line -- arguments to the process
387 * RETURN: ERROR / NO_ERROR
388 * EXT REFS: globals_used
389 * EXT EFFECTS: globals or other things altered
390 * ASSUMPTIONS:
391 * REVISIONS: 05/01/93 fix3810 clean-up
392 dd/mm/yy fix# fix_description
393 *--------------------------------------------------------------------*/
394 int UxExecSubproc(sp_vh, cmd_line)
395 handle sp_vh;
396 char *cmd_line;
397 {
398 if(UxExitSubproc(sp_vh) == ERROR)
399 return(ERROR);
400 if(UxRunSubproc(sp_vh, cmd_line) == ERROR)
401 return(ERROR);
402 return(NO_ERROR);
403 }
404
405
406 /*----------------------------------------------------------------------
407 * NAME: < int UxExitSubproc(sp_vh)>
408 * DESCRIPTION: <Remove the input source of the subprocess.
409 Kill the process and free the memory associated with
410 it.>
411 * PARAMETERS: handle sp_vh -- object handle
412 * RETURN: ERROR / NO_ERROR
413 * EXT REFS: UxSpArray
414 * EXT EFFECTS: UxSpArray
415 * ASSUMPTIONS:
416 * REVISIONS: 05/01/93 fix3810 clean-up
417 dd/mm/yy fix# fix_description
418 *--------------------------------------------------------------------*/
419 int UxExitSubproc(sp_vh)
420 handle sp_vh;
421 {
422 SubprocInfo_t *sp;
423
424 if (UxCheckIndex(sp_vh) == ERROR) {
425 return ERROR;
426 }
427
428 sp = UxSpArray[sp_vh];
429
430 if(sp->pid > 0)
431 {
432 kill(sp->pid, SIGKILL);
433 UxSpExit (sp);
434 }
435
436 return(NO_ERROR);
437 }
438
439
440 /*----------------------------------------------------------------------
441 * NAME: < int UxGetSubprocPid(sp_vh)>
442 * DESCRIPTION: <Test if the process is still alive and return
443 pid if it is not. If the process is dead, it
444 resets the pid field and closes the pseudo terminal
445 fd's if they are open.>
446 * PARAMETERS: handle sp_vh -- object handle
447 * RETURN: ERROR -1 if the subprocess object does not exist
448 0 if the process is dead
449 pid if the process is running
450 * EXT REFS: UxSpArray
451 * EXT EFFECTS: UxSpArray
452 * ASSUMPTIONS:
453 * REVISIONS: 19/12/91 fix3288
454 05/01/93 fix3810 clean-up
455 dd/mm/yy fix# fix_description
456 *--------------------------------------------------------------------*/
457 int UxGetSubprocPid(sp_vh)
458 handle sp_vh;
459 {
460 SubprocInfo_t *sp;
461
462 if(UxCheckIndex(sp_vh) == ERROR)
463 return(ERROR);
464 sp = UxSpArray[sp_vh];
465
466 if(sp->pid == -1){
467 error_msg(CGETS( MS_MISC_SUBPROC_NOACT,
468 DS_MS_MISC_SUBPROC_NOACT));
469 return(ERROR);
470 }
471 /** if there is a process id */
472 if(sp->pid > 0)
473 {
474 /* and the process is dead
475 -- reset the pid entry
476 -- close the pty/tty and reset the entries
477 -- remove the input source for X
478 */
479 if ((kill(sp->pid, 0) == -1) && (errno != EPERM))
480 {
481 sp->pid = -1;
482 /* UxSpExit (sp); */
483 }
484 }
485 return(sp->pid);
486 }
487
488
489 /*----------------------------------------------------------------------
490 * NAME: <int UxSendSubproc(sp_vh, tex)>
491 * DESCRIPTION: <send a text string to the subprocess
492 indicated by sp_vh>
493 * PARAMETERS handle *sp_vh - process handle
494 char *tex - string to pass to process
495 * RETURN: ERROR /NO_ERROR
496 * EXT REFS: globals_used
497 * EXT EFFECTS: globals or other things altered
498 * ASSUMPTIONS:
499 * REVISIONS: 05/01/93 fix3810 clean-up
500 dd/mm/yy fix# fix_description
501 *--------------------------------------------------------------------*/
502 int UxSendSubproc(sp_vh, tex)
503 handle sp_vh;
504 char *tex;
505 {
506 char *tbuff;
507 int ret;
508
509 if(UxCheckIndex(sp_vh) == ERROR)
510 return(ERROR);
511
512 if (UxSpArray[sp_vh]->subprocStatus == DELAYED_EXIT) {
513 UxError( CGETS( MS_MISC_HNDL_DELAYED_EXIT,
514 DS_MS_MISC_HNDL_DELAYED_EXIT));
515 return(ERROR);
516 }
517
518 if(tex == NULL) {
519 tex = "";
520 }
521
522 tbuff = (char *) UxMalloc((strlen(tex) + 2)*sizeof(char));
523
524 strcpy(tbuff, tex);
525 strcat(tbuff, "\n");
526
527 ret = UxSendSubprocNoCR(sp_vh, tbuff);
528
529 UxFree(tbuff);
530
531 return ret;
532 }
533
534
535 /*----------------------------------------------------------------------
536 * NAME: <int UxSendSubprocNoCR(sp_vh, tex)>
537 * DESCRIPTION: <send a message to the daemon indicating that some input
538 is there for a subprocess >
539 * PARAMETERS: handle sp_vh - process handle
540 char *tex - text string
541 * RETURN: ERROR/NO_ERROR
542 * EXT REFS: UxSpArray
543 * EXT EFFECTS: globals or other things altered
544 * ASSUMPTIONS:
545 * REVISIONS: 05/01/93 fix3810 clean-up
546 05/04/93 fix4074 message for errno = EAGAIN
547 dd/mm/yy fix# fix_description
548 *--------------------------------------------------------------------*/
549 int UxSendSubprocNoCR(sp_vh, tex)
550 handle sp_vh;
551 char *tex;
552 {
553 register int len;
554 SubprocInfo_t *sp;
555 spmd_input_t msg; /* viewed as input to subprocess */
556
557 if(tex == NULL) {
558 tex = "";
559 }
560
561 if(UxCheckIndex(sp_vh) == ERROR)
562 return(ERROR);
563
564 if (UxSpArray[sp_vh]->subprocStatus == DELAYED_EXIT) {
565 UxError( CGETS( MS_MISC_HNDL_DELAYED_EXIT,
566 DS_MS_MISC_HNDL_DELAYED_EXIT));
567 return(ERROR);
568 }
569
570 sp = UxSpArray[sp_vh];
571 UxSpCheck(sp);
572
573 /* sp_check() sets pid to -1 if process isn't there */
574 if(sp->pid == -1)
575 {
576 error_msg(CGETS( MS_MISC_SUBPROC_NOACT,
577 DS_MS_MISC_SUBPROC_NOACT));
578 return(ERROR);
579 }
580
581 len = strlen(tex);
582
583 msg.mtype = SPMD_INPUT; /* input from subprocess perspective */
584 msg.pid = sp->pid;
585 ASSERT (len < sizeof(msg.input)); /* Could use more messages.. */
586 strcpy (msg.input, tex);
587 if (msgsnd(UxSpmd.spmd_pc_msqid, &msg, len+sizeof(msg.pid), IPC_NOWAIT)
588 == -1)
589
590 {
591 if (errno == EAGAIN)
592 {
593 error_msg(CGETS(MS_MISC1_MSG_NOT_SENT,
594 DS_MS_MISC1_MSG_NOT_SENT));
595 }
596 else
597 {
598
599 UxInternalError(__FILE__, __LINE__,
600 CGETS( MS_MISC_W_SUBPROC_ERR, DS_MS_MISC_W_SUBPROC_ERR));
601 UxSpCheck(sp);
602 }
603 return(ERROR);
604 }
605 return(NO_ERROR);
606 }
607
608
609 /*----------------------------------------------------------------------
610 * NAME: <char * UxTransferToBuffer(fd, status)>
611 * DESCRIPTION: <Transfer data received from the process through the
612 daemon to the application>
613 * PARAMETERS: int fd - not used
614 int *status - returns 1 if there is more data
615 * RETURN: char * - pointer to data transferred
616 * EXT REFS: UxSpmd
617 * EXT EFFECTS: UxSpmd
618 * ASSUMPTIONS:
619 * REVISIONS: 05/01/93 fix3810 clean-up
620 08/01/93 fix3818 to remove r's at end for HP/IBM
621 25/03/93 fix4037 deal with multibyte
622 *--------------------------------------------------------------------*/
623
624 char * UxTransferToBuffer(fd, status)
625 int fd, *status;
626 {
627 int len;
628 static char text_buff[SIZEOFTEXTMSG];
629
630 if ((UxSpmd.spmd_rmsgrp == NULL) || (UxSpmd.spmd_rmsgsiz <= 0)) {
631 return (NULL); /* sanity checking failed */
632 }
633
634 /*
635 * Copying could be avoided by returning a pointer into
636 * UxSpmd.spmd_rmsgrp directly.
637 */
638 len = UxSpmd.spmd_rmsgsiz;
639 strncpy (text_buff, UxSpmd.spmd_rmsgrp, len);
640 text_buff[len] = '\0';
641
642 UxSpmd.spmd_rmsgsiz -= len; /* decrement remainder count */
643 UxSpmd.spmd_rmsgrp = NULL;
644 *status = 0;
645 return(text_buff);
646 }
647
648
649 /*----------------------------------------------------------------------
650 * NAME: <void UxAppendTo(fd, tw)>
651 * DESCRIPTION: <Output data received by application into widget>
652 * PARAMETERS: int fd - not used
653 Widget tw - widget to output data to
654 * RETURN: void
655 * EXT REFS: globals_used
656 * EXT EFFECTS: globals or other things altered
657 * ASSUMPTIONS:
658 * REVISIONS: 05/01/93 fix3810 clean-up
659 dd/mm/yy fix# fix_description
660 *--------------------------------------------------------------------*/
661 void UxAppendTo(fd, tw)
662 int fd;
663 Widget tw;
664 {
665 char *text;
666 int more;
667
668 while( (text = UxTransferToBuffer(fd, &more)) )
669 {
670 if(tw)
671 UxTextAppend(tw, text);
672 else
673 fprintf(stdout, "%s",text);
674
675 if(!more)
676 break;
677 }
678 }
679
680
681 /*----------------------------------------------------------------------
682 * NAME: <int UxSetSubprocClosure(sp_vh, data)>
683 * DESCRIPTION: <Sets the data/closure passed to the output function>
684 * PARAMETERS: handle sp_vh - handle to subproc
685 char *data - data passed to the
686 subprocess function
687 * RETURN: ERROR/NO_ERROR
688 * EXT REFS: UxSpArray
689 * EXT EFFECTS: UxSpArray
690 * ASSUMPTIONS:
691 * REVISIONS: 05/01/93 fix3810 clean-up
692 dd/mm/yy fix# fix_description
693 *--------------------------------------------------------------------*/
694 int UxSetSubprocClosure(sp_vh, data)
695 handle sp_vh;
696 char *data;
697 {
698 SubprocInfo_t *sp;
699
700 if(UxCheckIndex(sp_vh) == ERROR)
701 return(ERROR);
702 sp = UxSpArray[sp_vh];
703
704 sp->user_data = data;
705 return(NO_ERROR);
706 }
707
708
709 /*----------------------------------------------------------------------
710 * NAME: <int UxSetSubprocFunction(sp_vh, fnt)>
711 * DESCRIPTION: <Sets the output function that is executed on ouput
712 from the child process>
713 * PARAMETERS: handle sp_vh - handle to subproc
714 void (*fnt)() - output function
715 * RETURN: ERROR/NO_ERROR
716 * EXT REFS: UxSpArray
717 * EXT EFFECTS: UxSpArray
718 * ASSUMPTIONS:
719 * REVISIONS: 05/01/93 fix3810 clean-up
720 dd/mm/yy fix# fix_description
721 *--------------------------------------------------------------------*/
722 int UxSetSubprocFunction(sp_vh, fnt)
723 handle sp_vh;
724 void (*fnt)();
725 {
726 SubprocInfo_t *sp;
727
728 if (UxCheckIndex(sp_vh) == ERROR)
729 return(ERROR);
730
731 sp = UxSpArray[sp_vh];
732 sp->output_fnt = fnt;
733 return(NO_ERROR);
734 }