PipeTest.src 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. XCOMM! CDE_INSTALLATION_TOP/bin/dtksh
  2. XCOMM $XConsortium: PipeTest.src /main/3 1996/04/23 20:18:30 drk $
  3. XCOMM #########################################################################
  4. XCOMM (c) Copyright 1993, 1994 Hewlett-Packard Company
  5. XCOMM (c) Copyright 1993, 1994 International Business Machines Corp.
  6. XCOMM (c) Copyright 1993, 1994 Sun Microsystems, Inc.
  7. XCOMM (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of
  8. XCOMM Novell, Inc.
  9. XCOMM #########################################################################
  10. XCOMM
  11. XCOMM This sample shell script demonstrates some of the more advanced features
  12. XCOMM of dtksh. It shows how a structure can be defined and accessed, and
  13. XCOMM how a C library function can be called.
  14. XCOMM
  15. XCOMM Define a structure made up of 2 integer fields: pipe_in and pipe_out
  16. struct pipe_fds pipe_in:int pipe_out:int
  17. typedef 'struct pipe_fds *' pipe_fds_ptr
  18. echo "Test 1"
  19. XCOMM Malloc space for the structure, and initialize the fields
  20. call -F nop '@pipe_fds_ptr:{0,0}'
  21. PIPE_FDS=$RET
  22. XCOMM Call the pipe(2) kernel intrinsic
  23. call pipe $PIPE_FDS
  24. RESULT=$RET
  25. XCOMM Print the values of the fields in the structure
  26. call strprint pipe_fds_ptr $PIPE_FDS
  27. echo RESULT = $RESULT
  28. echo
  29. XCOMM Repeat the test, to make sure we get different file descriptors
  30. echo "Test 2"
  31. call -F nop '@pipe_fds_ptr:{0,0}'
  32. PIPE_FDS=$RET
  33. call pipe $PIPE_FDS
  34. RESULT=$RET
  35. call strprint pipe_fds_ptr $PIPE_FDS
  36. echo RESULT = $RESULT
  37. echo