Unix.st
author Claus Gittinger <cg@exept.de>
Fri, 10 Jan 1997 12:20:24 +0100
changeset 2117 460b14a6db96
parent 2107 9987b837fe12
child 2126 d3da2956f380
permissions -rw-r--r--
added a query for interrupts being blocked
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     1
"
5
67342904af11 *** empty log message ***
claus
parents: 3
diff changeset
     2
 COPYRIGHT (c) 1988 by Claus Gittinger
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
     3
	      All Rights Reserved
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     4
a27a279701f8 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
a27a279701f8 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
a27a279701f8 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
a27a279701f8 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
a27a279701f8 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
a27a279701f8 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
a27a279701f8 Initial revision
claus
parents:
diff changeset
    11
"
a27a279701f8 Initial revision
claus
parents:
diff changeset
    12
2080
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
    13
'From Smalltalk/X, Version:3.1.3 on 7-jan-1997 at 20:04:25'                     !
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
    14
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    15
Object subclass:#OperatingSystem
798
90a518c71a7f recursiveRemoveDirectory does not print garbage to stderr any longer; computeDateAndTimeFrom: now returns the utcOffset
Stefan Vogel <sv@exept.de>
parents: 792
diff changeset
    16
	instanceVariableNames:''
2080
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
    17
	classVariableNames:'HostName DomainName LastErrorNumber OSSignals
759
908363ce8a32 interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents: 756
diff changeset
    18
		SlowFork ForkFailed ErrorSignal AccessDeniedErrorSignal
1034
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
    19
		FileNotFoundErrorSignal LocaleInfo'
798
90a518c71a7f recursiveRemoveDirectory does not print garbage to stderr any longer; computeDateAndTimeFrom: now returns the utcOffset
Stefan Vogel <sv@exept.de>
parents: 792
diff changeset
    20
	poolDictionaries:''
90a518c71a7f recursiveRemoveDirectory does not print garbage to stderr any longer; computeDateAndTimeFrom: now returns the utcOffset
Stefan Vogel <sv@exept.de>
parents: 792
diff changeset
    21
	category:'System-Support'
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    22
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    23
2080
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
    24
Object subclass:#OSProcessStatus
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
    25
	instanceVariableNames:'pid status code core'
1966
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
    26
	classVariableNames:''
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
    27
	poolDictionaries:''
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
    28
	privateIn:OperatingSystem
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
    29
!
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
    30
2080
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
    31
Object subclass:#FileStatusInfo
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
    32
	instanceVariableNames:'type mode uid gid size id accessed modified statusChanged path'
1858
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
    33
	classVariableNames:''
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
    34
	poolDictionaries:''
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
    35
	privateIn:OperatingSystem
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
    36
!
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
    37
437
claus
parents: 434
diff changeset
    38
!OperatingSystem primitiveDefinitions!
406
claus
parents: 384
diff changeset
    39
%{
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
    40
#define UNIX_LIKE
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
    41
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
    42
#if defined(MSWINDOWS) || defined(OS2) || defined(MSDOS) || defined(WIN32)
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
    43
# ifndef MSDOS_LIKE
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
    44
#  define MSDOS_LIKE
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
    45
# endif
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
    46
# undef UNIX_LIKE
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
    47
# ifdef i386
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
    48
#  define _X86_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
    49
# endif
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
    50
#endif
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
    51
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
    52
#if defined(transputer)
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
    53
# undef MSDOS_LIKE
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
    54
# undef UNIX_LIKE
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
    55
#endif
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
    56
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
    57
#if defined(_AIX)
439
claus
parents: 438
diff changeset
    58
# ifndef WANT_REALPATH
claus
parents: 438
diff changeset
    59
#  define WANT_REALPATH
claus
parents: 438
diff changeset
    60
# endif
513
0347f6d11d76 interruptable system() on AIX
Claus Gittinger <cg@exept.de>
parents: 512
diff changeset
    61
# ifndef WANT_SYSTEM
0347f6d11d76 interruptable system() on AIX
Claus Gittinger <cg@exept.de>
parents: 512
diff changeset
    62
#  define WANT_SYSTEM
0347f6d11d76 interruptable system() on AIX
Claus Gittinger <cg@exept.de>
parents: 512
diff changeset
    63
# endif
406
claus
parents: 384
diff changeset
    64
#endif
claus
parents: 384
diff changeset
    65
433
f74d003548dc system-fix
claus
parents: 424
diff changeset
    66
#ifdef LINUX
1142
3964108b86ca *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1135
diff changeset
    67
  /* use inline string macros */
3964108b86ca *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1135
diff changeset
    68
# define __STRINGDEFS__
3964108b86ca *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1135
diff changeset
    69
# include <linuxIntern.h>
3964108b86ca *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1135
diff changeset
    70
439
claus
parents: 438
diff changeset
    71
# ifndef WANT_SYSTEM
claus
parents: 438
diff changeset
    72
#  define WANT_SYSTEM
claus
parents: 438
diff changeset
    73
# endif
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
    74
# define WANT_SHM
433
f74d003548dc system-fix
claus
parents: 424
diff changeset
    75
#endif
f74d003548dc system-fix
claus
parents: 424
diff changeset
    76
511
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
    77
#ifdef IRIX5
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
    78
# define WANT_SYSTEM
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
    79
#endif
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
    80
514
81fa80a953e2 system() now interruptable with ultrix
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
    81
#ifdef ultrix
81fa80a953e2 system() now interruptable with ultrix
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
    82
# define WANT_SYSTEM
81fa80a953e2 system() now interruptable with ultrix
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
    83
#endif
81fa80a953e2 system() now interruptable with ultrix
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
    84
515
43d76695a662 interruptable system() on hpux
Claus Gittinger <cg@exept.de>
parents: 514
diff changeset
    85
#ifdef hpux
43d76695a662 interruptable system() on hpux
Claus Gittinger <cg@exept.de>
parents: 514
diff changeset
    86
# define WANT_SYSTEM
43d76695a662 interruptable system() on hpux
Claus Gittinger <cg@exept.de>
parents: 514
diff changeset
    87
#endif
43d76695a662 interruptable system() on hpux
Claus Gittinger <cg@exept.de>
parents: 514
diff changeset
    88
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
    89
#ifdef solaris
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
    90
# define WANT_SYSTEM
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
    91
#endif
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
    92
805
850571f0255f WANT_SYSTEM for unixware.
Stefan Vogel <sv@exept.de>
parents: 803
diff changeset
    93
#if defined(SYSV4) && defined(i386) /* e.g. unixware */
520
9620f7dc79d2 interruptable system() on unixware - should now move WANT_SYSTEM into xxxIntern files
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    94
# define WANT_SYSTEM
9620f7dc79d2 interruptable system() on unixware - should now move WANT_SYSTEM into xxxIntern files
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    95
#endif
9620f7dc79d2 interruptable system() on unixware - should now move WANT_SYSTEM into xxxIntern files
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    96
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
    97
/*
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
    98
 * notice: although many systems' include files
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
    99
 * already block against multiple inclusion, some
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   100
 * do not. Therefore, this is done here again.
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   101
 * (it does not hurt)
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   102
 */ 
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   103
439
claus
parents: 438
diff changeset
   104
#ifdef WANT_REALPATH
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   105
439
claus
parents: 438
diff changeset
   106
# include <sys/param.h>
claus
parents: 438
diff changeset
   107
# define _SYS_PARAM_H_INCLUDED_
claus
parents: 438
diff changeset
   108
claus
parents: 438
diff changeset
   109
# include <errno.h>
claus
parents: 438
diff changeset
   110
# define _ERRNO_H_INCLUDED_
claus
parents: 438
diff changeset
   111
claus
parents: 438
diff changeset
   112
# include <sys/stat.h>
claus
parents: 438
diff changeset
   113
# define _SYS_STAT_H_INCLUDED_
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   114
439
claus
parents: 438
diff changeset
   115
#endif /* WANT_REALPATH */
claus
parents: 438
diff changeset
   116
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   117
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   118
434
0511ecb7c818 *** empty log message ***
claus
parents: 433
diff changeset
   119
#ifdef WANT_SHM
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   120
extern int shmctl(), shmget(), shmdt();
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   121
extern char * shmat();
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   122
434
0511ecb7c818 *** empty log message ***
claus
parents: 433
diff changeset
   123
# include <sys/types.h>
437
claus
parents: 434
diff changeset
   124
# define _SYS_TYPES_H_INCLUDED_
439
claus
parents: 438
diff changeset
   125
434
0511ecb7c818 *** empty log message ***
claus
parents: 433
diff changeset
   126
# include <sys/ipc.h>
437
claus
parents: 434
diff changeset
   127
# define _SYS_IPC_H_INCLUDED_
439
claus
parents: 438
diff changeset
   128
434
0511ecb7c818 *** empty log message ***
claus
parents: 433
diff changeset
   129
# include <sys/shm.h>
437
claus
parents: 434
diff changeset
   130
# define _SYS_SHM_H_INCLUDED_
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   131
439
claus
parents: 438
diff changeset
   132
#endif /* WANT_SHM */
434
0511ecb7c818 *** empty log message ***
claus
parents: 433
diff changeset
   133
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   134
434
0511ecb7c818 *** empty log message ***
claus
parents: 433
diff changeset
   135
#ifdef IRIX5
0511ecb7c818 *** empty log message ***
claus
parents: 433
diff changeset
   136
# include <sys/syssgi.h>
0511ecb7c818 *** empty log message ***
claus
parents: 433
diff changeset
   137
#endif
511
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   138
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   139
511
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   140
#ifdef transputer
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   141
511
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   142
# define unlink(f)      ((remove(f) == 0) ? 0 : -1)
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   143
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   144
#else /* not transputer */
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   145
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   146
# ifndef _SIGNAL_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   147
#  include <signal.h>
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   148
#  define _SIGNAL_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   149
# endif
511
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   150
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   151
# ifdef SYSV
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   152
#  ifndef _SYS_TYPES_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   153
#   include <sys/types.h>
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   154
#   define _SYS_TYPES_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   155
#  endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   156
#  ifndef _SYS_PARAM_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   157
#   include <sys/param.h>
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   158
#   define _SYS_PARAM_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   159
#  endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   160
#  ifndef _SYS_TIMES_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   161
#   include <sys/times.h>
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   162
#   define _SYS_TIMES_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   163
#  endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   164
#  ifndef _SYS_FILE_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   165
#   include <sys/file.h>
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   166
#   define _SYS_FILE_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   167
#  endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   168
511
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   169
#  if ! defined(sco3_2)
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   170
#   ifndef _UNISTD_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   171
#    include <unistd.h>
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   172
#    define _UNISTD_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   173
#   endif
511
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   174
#  endif
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   175
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   176
#  if defined(isc3_2) || defined(sco3_2)
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   177
#   ifndef _SYS_TIME_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   178
#    include <sys/time.h>
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   179
#    define _SYS_TIME_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   180
#   endif
511
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   181
#  endif
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   182
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   183
#  if !defined(isc3_2)
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   184
#   if defined(PCS) && defined(mips)
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   185
#    include "/usr/include/bsd/sys/time.h"
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   186
#    include "/usr/include/sys/time.h"
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   187
#   else
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   188
#    ifndef _TIME_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   189
#     include <time.h>
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   190
#     define _TIME_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   191
#    endif
511
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   192
#   endif
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   193
#  endif
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   194
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   195
#  if defined(isc3_2)
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   196
#   include <sys/bsdtypes.h>
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   197
#  endif
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   198
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   199
# else /* not SYSV */
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   200
802
087384994c4a even worse
Claus Gittinger <cg@exept.de>
parents: 801
diff changeset
   201
#  ifdef MSDOS_LIKE
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   202
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   203
#   ifndef _SYS_TYPES_H_INCLUDED_
1987
8249e9134622 win32 changes
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   204
#    include <types.h>
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   205
#    define _SYS_TYPES_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   206
#   endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   207
#   ifndef _TIME_H_INCLUDED_
1987
8249e9134622 win32 changes
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   208
#    include <C:\mstools\h\time.h>
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   209
#    define _TIME_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   210
#   endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   211
#   ifndef _SYS_TIMEB_H_INCLUDED_
1987
8249e9134622 win32 changes
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   212
#    include <timeb.h>
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   213
#    define _SYS_TIMEB_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   214
#   endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   215
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   216
#  else /* not MSDOS_like */
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   217
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   218
#   ifndef _SYS_TIME_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   219
#    include <sys/time.h>
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   220
#    define _SYS_TIME_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   221
#   endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   222
#   ifndef _SYS_TYPES_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   223
#    include <sys/types.h>
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   224
#    define _SYS_TYPES_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   225
#   endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   226
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   227
#  endif /* not MSDOS */
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
   228
# endif /* not SYSV */
511
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   229
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   230
# ifdef aix
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   231
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   232
#  ifndef _TIME_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   233
#   include <time.h>
914
d00401a9450e Fix syntax error (#defined -> #define).
Stefan Vogel <sv@exept.de>
parents: 855
diff changeset
   234
#   define _TIME_H_INCLUDED_
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   235
#  endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   236
#  ifndef _SYS_SELECT_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   237
#   include <sys/select.h>
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   238
#   define _SYS_SELECT_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   239
#  endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   240
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
   241
# endif /* aix */
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
   242
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
   243
# ifndef MSDOS_LIKE
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
   244
#  include <pwd.h>
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
   245
#  include <grp.h>
511
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   246
# endif
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   247
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   248
# ifndef _SYS_STAT_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   249
#  include <sys/stat.h>
1616
fa734ea238f8 type & include file.h on all systems
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
   250
#  define _SYS_STAT_H_INCLUDED_
fa734ea238f8 type & include file.h on all systems
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
   251
# endif
fa734ea238f8 type & include file.h on all systems
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
   252
fa734ea238f8 type & include file.h on all systems
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
   253
# ifndef _SYS_FILE_H_INCLUDED_
1633
dc4105e87116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1632
diff changeset
   254
#  ifndef WIN32
dc4105e87116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1632
diff changeset
   255
#   include <sys/file.h>
dc4105e87116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1632
diff changeset
   256
#  endif
1616
fa734ea238f8 type & include file.h on all systems
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
   257
#  define _SYS_FILE_H_INCLUDED_
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   258
# endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   259
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   260
# ifndef _ERRNO_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   261
#  include <errno.h>
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   262
#  define _ERRNO_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   263
# endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   264
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   265
# ifndef _STDIO_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   266
#  include <stdio.h>
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   267
#  define _STDIO_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   268
# endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   269
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   270
# ifndef _FCNTL_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   271
#  include <fcntl.h>
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   272
#  define _FCNTL_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   273
# endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   274
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   275
# ifdef WIN32
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   276
#  define USE_TimerProc
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   277
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   278
#  undef INT
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   279
#  undef Array
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   280
#  undef Number
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   281
#  undef Method
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   282
#  undef Point
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   283
#  undef Rectangle
1987
8249e9134622 win32 changes
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   284
#  undef Block
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   285
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   286
/* #  include <windows.h> /* */
1987
8249e9134622 win32 changes
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   287
#  include <stdarg.h> /* */
8249e9134622 win32 changes
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   288
#  include <windef.h> /* */
8249e9134622 win32 changes
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   289
#  include <winbase.h> /* */
8249e9134622 win32 changes
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   290
#  include <wingdi.h> /* */
8249e9134622 win32 changes
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   291
#  include <winuser.h> /* */
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   292
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   293
#  ifndef USE_TimerProc
1987
8249e9134622 win32 changes
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   294
#   include <mmsystem.h> /* */
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   295
#  else
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   296
    static UINT w32TimerId;
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   297
#  endif
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   298
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   299
#  ifdef __DEF_Array
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   300
#   define Array __DEF_Array
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   301
#  endif
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   302
#  ifdef __DEF_Number
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   303
#   define Number __DEF_Number
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   304
#  endif
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   305
#  ifdef __DEF_Method
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   306
#   define Method __DEF_Method
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   307
#  endif
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   308
#  ifdef __DEF_Point
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   309
#   define Point __DEF_Point
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   310
#  endif
1987
8249e9134622 win32 changes
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   311
#  ifdef __DEF_Block
8249e9134622 win32 changes
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   312
#   define Block __DEF_Block
8249e9134622 win32 changes
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   313
#  endif
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   314
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   315
#  define stat _stat
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   316
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   317
# endif /* WIN32 */
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   318
511
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   319
813
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
   320
# if defined(LINUX)
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
   321
#  define HAS_LOCALECONV
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
   322
# endif
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
   323
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
   324
# if defined (HAS_LOCALECONV)
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
   325
#  ifndef _LOCALE_H_INCLUDED_
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
   326
#   include <locale.h>
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
   327
#   define _LOCALE_H_INCLUDED_
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
   328
#  endif
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
   329
# endif
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
   330
511
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   331
/* 
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   332
 * posix systems should define these ... 
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   333
 * but on some (older) systems, they are not.
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   334
 */
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   335
# ifndef S_IXUSR
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   336
#  ifdef S_IEXEC
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   337
#   define S_IXUSR S_IEXEC
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   338
#   define S_IXGRP (S_IEXEC>>3)
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   339
#   define S_IXOTH (S_IEXEC>>6)
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   340
#  endif
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   341
# endif
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   342
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   343
# ifndef S_IXUSR
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   344
#  define S_IXUSR 0100
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   345
#  define S_IXGRP 0010
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   346
#  define S_IXOTH 0001
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   347
# endif
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   348
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   349
# ifndef S_IRUSR
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   350
#  define S_IRUSR 0400
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   351
#  define S_IRGRP 0040
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   352
#  define S_IROTH 0004
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   353
# endif
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   354
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   355
# ifndef S_IWUSR
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   356
#  define S_IWUSR 0200
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   357
#  define S_IWGRP 0020
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   358
#  define S_IWOTH 0002
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   359
# endif
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   360
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   361
# ifndef MAXPATHLEN
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
   362
#  ifndef MSDOS_LIKE
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
   363
#   include <sys/param.h>
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
   364
#  endif
511
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   365
#  ifndef MAXPATHLEN
813
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
   366
#   ifdef FILENAME_MAX  /* i.e. MSDOS_LIKE */
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
   367
#    define MAXPATHLEN FILENAME_MAX
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
   368
#   else
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
   369
#    define MAXPATHLEN 1024
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
   370
#   endif
511
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   371
#  endif
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   372
# endif
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   373
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   374
# if defined(HAS_UNAME)
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   375
#  include <sys/utsname.h>
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   376
# endif
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   377
754
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
   378
# if defined(SYSV4)
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
   379
#  include <stropts.h>
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
   380
# endif
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
   381
763
7d5e32ed435e dummy SA_xxx defs for systems which dont have them (HP & ultrix)
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
   382
/*
2073
4c2bdfc668c9 NEXT changes (again)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
   383
 * NeXT has no pid_t
2107
9987b837fe12 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2098
diff changeset
   384
 * and no sigemptyset
2073
4c2bdfc668c9 NEXT changes (again)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
   385
 */
4c2bdfc668c9 NEXT changes (again)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
   386
# ifdef NEXT
4c2bdfc668c9 NEXT changes (again)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
   387
   typedef int pid_t;
2107
9987b837fe12 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2098
diff changeset
   388
#  define sigemptyset(set)      ((*(set) = 0L), 0)
2073
4c2bdfc668c9 NEXT changes (again)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
   389
# endif
4c2bdfc668c9 NEXT changes (again)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
   390
4c2bdfc668c9 NEXT changes (again)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
   391
/*
4c2bdfc668c9 NEXT changes (again)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
   392
 * some (BSD ?) have no timezone
4c2bdfc668c9 NEXT changes (again)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
   393
 */
4c2bdfc668c9 NEXT changes (again)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
   394
# if defined(ultrix) || defined(sunos) || defined(NEXT)
4c2bdfc668c9 NEXT changes (again)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
   395
#  define HAS_NO_TIMEZONE
4c2bdfc668c9 NEXT changes (again)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
   396
# endif
4c2bdfc668c9 NEXT changes (again)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
   397
4c2bdfc668c9 NEXT changes (again)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
   398
/*
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
   399
 * sigaction dummies (you won't believe these call themself ``POSIX'' systems ...)
763
7d5e32ed435e dummy SA_xxx defs for systems which dont have them (HP & ultrix)
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
   400
 */
7d5e32ed435e dummy SA_xxx defs for systems which dont have them (HP & ultrix)
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
   401
# ifndef SA_RESTART
813
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
   402
#  define SA_RESTART    0
763
7d5e32ed435e dummy SA_xxx defs for systems which dont have them (HP & ultrix)
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
   403
# endif
7d5e32ed435e dummy SA_xxx defs for systems which dont have them (HP & ultrix)
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
   404
# ifndef SA_SIGINFO
813
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
   405
#  define SA_SIGINFO    0
763
7d5e32ed435e dummy SA_xxx defs for systems which dont have them (HP & ultrix)
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
   406
# endif
7d5e32ed435e dummy SA_xxx defs for systems which dont have them (HP & ultrix)
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
   407
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
   408
# if defined(HAS_WAITPID) || defined(HAS_WAIT3)
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
   409
#  include <sys/wait.h>
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
   410
# endif
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
   411
1433
8b2eacaea59c Getdomainname for Unixware.
Stefan Vogel <sv@exept.de>
parents: 1422
diff changeset
   412
# if defined(HAS_SYSINFO)
8b2eacaea59c Getdomainname for Unixware.
Stefan Vogel <sv@exept.de>
parents: 1422
diff changeset
   413
#  include <sys/systeminfo.h>
8b2eacaea59c Getdomainname for Unixware.
Stefan Vogel <sv@exept.de>
parents: 1422
diff changeset
   414
# endif
8b2eacaea59c Getdomainname for Unixware.
Stefan Vogel <sv@exept.de>
parents: 1422
diff changeset
   415
1615
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
   416
#endif /* not transputer */
511
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   417
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   418
/*
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   419
 * on some systems errno is a macro ... check for it here
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   420
 */
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   421
#ifndef errno
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   422
 extern errno;
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   423
#endif
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   424
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   425
/*
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   426
 * some (old ?) systems do not define this ...
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   427
 */
675
f3461db7a0ee avoid a warning
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   428
#if !defined(R_OK) && !defined(_AIX)
511
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   429
# define R_OK    4       /* Test for Read permission */ 
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   430
# define W_OK    2       /* Test for Write permission */
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   431
# define X_OK    1       /* Test for eXecute permission */
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   432
# define F_OK    0       /* Test for existence of File */
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   433
#endif
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   434
832
70e8b7fc357e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 831
diff changeset
   435
#ifdef WIN32
70e8b7fc357e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 831
diff changeset
   436
# define SIGHANDLER_ARG int
70e8b7fc357e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 831
diff changeset
   437
#else
70e8b7fc357e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 831
diff changeset
   438
# define SIGHANDLER_ARG
70e8b7fc357e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 831
diff changeset
   439
#endif
70e8b7fc357e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 831
diff changeset
   440
1441
91284e90f42a sunos has no __wait
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   441
#ifdef sunos
91284e90f42a sunos has no __wait
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   442
# define NO_WAITPID
91284e90f42a sunos has no __wait
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   443
#endif
91284e90f42a sunos has no __wait
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   444
437
claus
parents: 434
diff changeset
   445
%}
claus
parents: 434
diff changeset
   446
! !
claus
parents: 434
diff changeset
   447
claus
parents: 434
diff changeset
   448
!OperatingSystem primitiveFunctions!
claus
parents: 434
diff changeset
   449
%{
claus
parents: 434
diff changeset
   450
claus
parents: 434
diff changeset
   451
/*
claus
parents: 434
diff changeset
   452
 * some systems' system() is broken in that it does not correctly 
claus
parents: 434
diff changeset
   453
 * handle EINTR and returns failure even though it actually succeeded. 
claus
parents: 434
diff changeset
   454
 * (LINUX is one of them)
claus
parents: 434
diff changeset
   455
 * Here is a fixed version. If you encounter EINTR returns from
claus
parents: 434
diff changeset
   456
 * OperatingSystem>>executeCommand, you ought to define WANT_SYSTEM
claus
parents: 434
diff changeset
   457
 * in the xxxIntern.h file to get this fixed version.
claus
parents: 434
diff changeset
   458
 *
claus
parents: 434
diff changeset
   459
 * As an added BONUS, this system() enables interrupts while waiting
claus
parents: 434
diff changeset
   460
 * for the child which enables other threads to continue.
507
a7780fc27ee9 mad system interuptable (needs WANT_SYSTEM to be defined in xxxIntern.h)
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   461
 * (i.e. it is RT safe)
437
claus
parents: 434
diff changeset
   462
 */
511
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   463
433
f74d003548dc system-fix
claus
parents: 424
diff changeset
   464
#if defined(WANT_SYSTEM)
f74d003548dc system-fix
claus
parents: 424
diff changeset
   465
434
0511ecb7c818 *** empty log message ***
claus
parents: 433
diff changeset
   466
/* # define DPRINTF(x)     printf x */
0511ecb7c818 *** empty log message ***
claus
parents: 433
diff changeset
   467
# define DPRINTF(x)     /* nothing */
433
f74d003548dc system-fix
claus
parents: 424
diff changeset
   468
437
claus
parents: 434
diff changeset
   469
# ifndef _STDDEF_H_INCLUDED_
claus
parents: 434
diff changeset
   470
#  include <stddef.h>
claus
parents: 434
diff changeset
   471
#  define _STDDEF_H_INCLUDED_
claus
parents: 434
diff changeset
   472
# endif
claus
parents: 434
diff changeset
   473
claus
parents: 434
diff changeset
   474
# ifndef _STDLIB_H_INCLUDED_
claus
parents: 434
diff changeset
   475
#  include <stdlib.h>
claus
parents: 434
diff changeset
   476
#  define _STDLIB_H_INCLUDED_
claus
parents: 434
diff changeset
   477
# endif
claus
parents: 434
diff changeset
   478
claus
parents: 434
diff changeset
   479
# ifndef _UNISTD_H_INCLUDED_
claus
parents: 434
diff changeset
   480
#  include <unistd.h>
claus
parents: 434
diff changeset
   481
#  define _UNISTD_H_INCLUDED_
claus
parents: 434
diff changeset
   482
# endif
claus
parents: 434
diff changeset
   483
claus
parents: 434
diff changeset
   484
# ifndef _SYS_WAIT_H_INCLUDED
claus
parents: 434
diff changeset
   485
#  include <sys/wait.h>
claus
parents: 434
diff changeset
   486
#  define _SYS_WAIT_H_INCLUDED
claus
parents: 434
diff changeset
   487
# endif
claus
parents: 434
diff changeset
   488
claus
parents: 434
diff changeset
   489
# ifndef _SIGNAL_H_INCLUDED_
claus
parents: 434
diff changeset
   490
#  include <signal.h>
claus
parents: 434
diff changeset
   491
#  define _SIGNAL_H_INCLUDED_
claus
parents: 434
diff changeset
   492
# endif
claus
parents: 434
diff changeset
   493
claus
parents: 434
diff changeset
   494
# ifndef _SYS_TYPES_H_INCLUDED_
claus
parents: 434
diff changeset
   495
#  include <sys/types.h>
claus
parents: 434
diff changeset
   496
#  define _SYS_TYPES_H_INCLUDED_
claus
parents: 434
diff changeset
   497
# endif
433
f74d003548dc system-fix
claus
parents: 424
diff changeset
   498
511
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   499
# if (!defined(HAVE_GNU_LD) && !defined (__ELF__)) || !defined(LINUX)
433
f74d003548dc system-fix
claus
parents: 424
diff changeset
   500
#  define       __environ       environ
512
f440411a55e4 no redef warnings on LINUX
Claus Gittinger <cg@exept.de>
parents: 511
diff changeset
   501
#  if !defined(LINUX)
530
07d0bce293c9 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 520
diff changeset
   502
#   define      __sigemptyset   sigemptyset
07d0bce293c9 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 520
diff changeset
   503
#   define      __sigaction     sigaction
07d0bce293c9 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 520
diff changeset
   504
#   define      __sigaddset     sigaddset
07d0bce293c9 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 520
diff changeset
   505
#   define      __sigprocmask   sigprocmask
07d0bce293c9 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 520
diff changeset
   506
#   define      __execve        execve
07d0bce293c9 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 520
diff changeset
   507
#   define      __wait          wait
07d0bce293c9 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 520
diff changeset
   508
#   define      __waitpid       waitpid
674
fba47329ac9d fixed startProcess
Claus Gittinger <cg@exept.de>
parents: 670
diff changeset
   509
#   if defined(HAS_VFORK)
530
07d0bce293c9 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 520
diff changeset
   510
#    define     FORK            vfork
514
81fa80a953e2 system() now interruptable with ultrix
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   511
#   else
530
07d0bce293c9 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 520
diff changeset
   512
#    define     FORK            fork
514
81fa80a953e2 system() now interruptable with ultrix
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   513
#   endif
512
f440411a55e4 no redef warnings on LINUX
Claus Gittinger <cg@exept.de>
parents: 511
diff changeset
   514
#  endif /* ! LINUX */
511
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   515
   extern char **environ;
433
f74d003548dc system-fix
claus
parents: 424
diff changeset
   516
# endif
f74d003548dc system-fix
claus
parents: 424
diff changeset
   517
f74d003548dc system-fix
claus
parents: 424
diff changeset
   518
# define        SHELL_PATH      "/bin/sh"       /* Path of the shell.  */
f74d003548dc system-fix
claus
parents: 424
diff changeset
   519
# define        SHELL_NAME      "sh"            /* Name to give it.  */
f74d003548dc system-fix
claus
parents: 424
diff changeset
   520
f74d003548dc system-fix
claus
parents: 424
diff changeset
   521
# ifndef        FORK
f74d003548dc system-fix
claus
parents: 424
diff changeset
   522
#  define       FORK    __fork
f74d003548dc system-fix
claus
parents: 424
diff changeset
   523
# endif
f74d003548dc system-fix
claus
parents: 424
diff changeset
   524
f74d003548dc system-fix
claus
parents: 424
diff changeset
   525
# ifndef CONST
f74d003548dc system-fix
claus
parents: 424
diff changeset
   526
#  ifdef __GNUC__
f74d003548dc system-fix
claus
parents: 424
diff changeset
   527
#   define CONST const
f74d003548dc system-fix
claus
parents: 424
diff changeset
   528
#  else
f74d003548dc system-fix
claus
parents: 424
diff changeset
   529
#   define CONST /* nothing */
f74d003548dc system-fix
claus
parents: 424
diff changeset
   530
#  endif
f74d003548dc system-fix
claus
parents: 424
diff changeset
   531
# endif
f74d003548dc system-fix
claus
parents: 424
diff changeset
   532
670
4d6d0c031711 startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents: 640
diff changeset
   533
static int
511
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   534
mySystem(line)
433
f74d003548dc system-fix
claus
parents: 424
diff changeset
   535
    register CONST char *line;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   536
{
f74d003548dc system-fix
claus
parents: 424
diff changeset
   537
    int status, save;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   538
    pid_t pid;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   539
    struct sigaction sa, intr, quit;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   540
    sigset_t block, omask;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   541
f74d003548dc system-fix
claus
parents: 424
diff changeset
   542
    if (line == NULL)
670
4d6d0c031711 startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents: 640
diff changeset
   543
	return -1;
433
f74d003548dc system-fix
claus
parents: 424
diff changeset
   544
f74d003548dc system-fix
claus
parents: 424
diff changeset
   545
    sa.sa_handler = SIG_IGN;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   546
    sa.sa_flags = 0;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   547
    __sigemptyset (&sa.sa_mask);
f74d003548dc system-fix
claus
parents: 424
diff changeset
   548
f74d003548dc system-fix
claus
parents: 424
diff changeset
   549
    if (__sigaction (SIGINT, &sa, &intr) < 0) {
f74d003548dc system-fix
claus
parents: 424
diff changeset
   550
	DPRINTF(("1: errno=%d\n", errno));
f74d003548dc system-fix
claus
parents: 424
diff changeset
   551
	return -1;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   552
    }
f74d003548dc system-fix
claus
parents: 424
diff changeset
   553
    if (__sigaction (SIGQUIT, &sa, &quit) < 0) {
f74d003548dc system-fix
claus
parents: 424
diff changeset
   554
	save = errno;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   555
	(void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL);
f74d003548dc system-fix
claus
parents: 424
diff changeset
   556
	errno = save;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   557
	DPRINTF(("2: errno=%d\n", errno));
f74d003548dc system-fix
claus
parents: 424
diff changeset
   558
	return -1;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   559
    }
f74d003548dc system-fix
claus
parents: 424
diff changeset
   560
f74d003548dc system-fix
claus
parents: 424
diff changeset
   561
    __sigemptyset (&block);
f74d003548dc system-fix
claus
parents: 424
diff changeset
   562
    __sigaddset (&block, SIGCHLD);
f74d003548dc system-fix
claus
parents: 424
diff changeset
   563
    save = errno;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   564
    if (__sigprocmask(SIG_BLOCK, &block, &omask) < 0) {
f74d003548dc system-fix
claus
parents: 424
diff changeset
   565
	if (errno == ENOSYS)
f74d003548dc system-fix
claus
parents: 424
diff changeset
   566
	    errno = save;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   567
	else {
f74d003548dc system-fix
claus
parents: 424
diff changeset
   568
	    save = errno;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   569
	    (void) __sigaction(SIGINT, &intr, (struct sigaction *) NULL);
f74d003548dc system-fix
claus
parents: 424
diff changeset
   570
	    (void) __sigaction(SIGQUIT, &quit, (struct sigaction *) NULL);
f74d003548dc system-fix
claus
parents: 424
diff changeset
   571
	    errno = save;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   572
	    DPRINTF(("3: errno=%d\n", errno));
f74d003548dc system-fix
claus
parents: 424
diff changeset
   573
	    return -1;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   574
	}
f74d003548dc system-fix
claus
parents: 424
diff changeset
   575
    }
f74d003548dc system-fix
claus
parents: 424
diff changeset
   576
f74d003548dc system-fix
claus
parents: 424
diff changeset
   577
    pid = FORK ();
f74d003548dc system-fix
claus
parents: 424
diff changeset
   578
    if (pid == (pid_t) 0) {
f74d003548dc system-fix
claus
parents: 424
diff changeset
   579
	/* Child side.  */
f74d003548dc system-fix
claus
parents: 424
diff changeset
   580
	CONST char *new_argv[4];
f74d003548dc system-fix
claus
parents: 424
diff changeset
   581
	new_argv[0] = SHELL_NAME;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   582
	new_argv[1] = "-c";
f74d003548dc system-fix
claus
parents: 424
diff changeset
   583
	new_argv[2] = line;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   584
	new_argv[3] = NULL;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   585
f74d003548dc system-fix
claus
parents: 424
diff changeset
   586
	/* Restore the signals.  */
f74d003548dc system-fix
claus
parents: 424
diff changeset
   587
	(void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL);
f74d003548dc system-fix
claus
parents: 424
diff changeset
   588
	(void) __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL);
f74d003548dc system-fix
claus
parents: 424
diff changeset
   589
	(void) __sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL);
f74d003548dc system-fix
claus
parents: 424
diff changeset
   590
f74d003548dc system-fix
claus
parents: 424
diff changeset
   591
	/* Exec the shell.  */
f74d003548dc system-fix
claus
parents: 424
diff changeset
   592
	(void) __execve (SHELL_PATH, (char *CONST *) new_argv, __environ);
f74d003548dc system-fix
claus
parents: 424
diff changeset
   593
	_exit (127);
f74d003548dc system-fix
claus
parents: 424
diff changeset
   594
    } else {
f74d003548dc system-fix
claus
parents: 424
diff changeset
   595
	if (pid < (pid_t) 0) {
f74d003548dc system-fix
claus
parents: 424
diff changeset
   596
	    /* The fork failed.  */
f74d003548dc system-fix
claus
parents: 424
diff changeset
   597
	    DPRINTF(("4: errno=%d\n", errno));
f74d003548dc system-fix
claus
parents: 424
diff changeset
   598
	    status = -1;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   599
	} else {
f74d003548dc system-fix
claus
parents: 424
diff changeset
   600
	    /* Parent side.  */
f74d003548dc system-fix
claus
parents: 424
diff changeset
   601
#ifdef  NO_WAITPID
f74d003548dc system-fix
claus
parents: 424
diff changeset
   602
	    pid_t child;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   603
f74d003548dc system-fix
claus
parents: 424
diff changeset
   604
	    do {
805
850571f0255f WANT_SYSTEM for unixware.
Stefan Vogel <sv@exept.de>
parents: 803
diff changeset
   605
		__BEGIN_INTERRUPTABLE__
433
f74d003548dc system-fix
claus
parents: 424
diff changeset
   606
		child = __wait (&status);
813
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
   607
		__END_INTERRUPTABLE__
805
850571f0255f WANT_SYSTEM for unixware.
Stefan Vogel <sv@exept.de>
parents: 803
diff changeset
   608
		if (child < 0 && errno != EINTR) {
433
f74d003548dc system-fix
claus
parents: 424
diff changeset
   609
		    DPRINTF(("5: errno=%d\n", errno));
f74d003548dc system-fix
claus
parents: 424
diff changeset
   610
		    status = -1;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   611
		    break;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   612
		}
f74d003548dc system-fix
claus
parents: 424
diff changeset
   613
	    } while (child != pid);
f74d003548dc system-fix
claus
parents: 424
diff changeset
   614
#else
f74d003548dc system-fix
claus
parents: 424
diff changeset
   615
	    pid_t child;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   616
f74d003548dc system-fix
claus
parents: 424
diff changeset
   617
	    /* claus: the original did not care for EINTR here ... */
f74d003548dc system-fix
claus
parents: 424
diff changeset
   618
	    do {
805
850571f0255f WANT_SYSTEM for unixware.
Stefan Vogel <sv@exept.de>
parents: 803
diff changeset
   619
		__BEGIN_INTERRUPTABLE__
433
f74d003548dc system-fix
claus
parents: 424
diff changeset
   620
		child = __waitpid (pid, &status, 0);
813
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
   621
		__END_INTERRUPTABLE__
433
f74d003548dc system-fix
claus
parents: 424
diff changeset
   622
	    } while ((child != pid) && (errno == EINTR));
f74d003548dc system-fix
claus
parents: 424
diff changeset
   623
	    if (child != pid) {
f74d003548dc system-fix
claus
parents: 424
diff changeset
   624
		DPRINTF(("6: errno=%d\n", errno));
f74d003548dc system-fix
claus
parents: 424
diff changeset
   625
		status = -1;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   626
	    }
f74d003548dc system-fix
claus
parents: 424
diff changeset
   627
#endif /* NO_WAITPID */
f74d003548dc system-fix
claus
parents: 424
diff changeset
   628
	}
f74d003548dc system-fix
claus
parents: 424
diff changeset
   629
    }
f74d003548dc system-fix
claus
parents: 424
diff changeset
   630
    save = errno;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   631
    if ((__sigaction (SIGINT, &intr, (struct sigaction *) NULL)
f74d003548dc system-fix
claus
parents: 424
diff changeset
   632
     | __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL)
f74d003548dc system-fix
claus
parents: 424
diff changeset
   633
     | __sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL)) != 0) {
f74d003548dc system-fix
claus
parents: 424
diff changeset
   634
	if (errno == ENOSYS) {
f74d003548dc system-fix
claus
parents: 424
diff changeset
   635
	    errno = save;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   636
	} else {
f74d003548dc system-fix
claus
parents: 424
diff changeset
   637
	    status = -1;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   638
	    DPRINTF(("7: errno=%d\n", errno));
f74d003548dc system-fix
claus
parents: 424
diff changeset
   639
	}
f74d003548dc system-fix
claus
parents: 424
diff changeset
   640
    }
f74d003548dc system-fix
claus
parents: 424
diff changeset
   641
f74d003548dc system-fix
claus
parents: 424
diff changeset
   642
    return status;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   643
}
1441
91284e90f42a sunos has no __wait
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   644
#else
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   645
# define __wait wait
433
f74d003548dc system-fix
claus
parents: 424
diff changeset
   646
#endif /* WANT_SYSTEM */
f74d003548dc system-fix
claus
parents: 424
diff changeset
   647
670
4d6d0c031711 startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents: 640
diff changeset
   648
433
f74d003548dc system-fix
claus
parents: 424
diff changeset
   649
/*
f74d003548dc system-fix
claus
parents: 424
diff changeset
   650
 * some systems do not have realpath();
f74d003548dc system-fix
claus
parents: 424
diff changeset
   651
 * the alternative of reading from a 'pwp'-pipe
f74d003548dc system-fix
claus
parents: 424
diff changeset
   652
 * is way too slow. Here is a realpath for the rest of us.
440
claus
parents: 439
diff changeset
   653
 * define WANT_REALPATH in the xxxIntern-file to get it.
433
f74d003548dc system-fix
claus
parents: 424
diff changeset
   654
 */
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   655
440
claus
parents: 439
diff changeset
   656
#if defined(HAS_REALPATH)
claus
parents: 439
diff changeset
   657
# undef WANT_REALPATH
claus
parents: 439
diff changeset
   658
#endif
claus
parents: 439
diff changeset
   659
#if !defined(HAS_GETWD) && !defined(HAS_GETCWD)
claus
parents: 439
diff changeset
   660
# undef WANT_REALPATH
claus
parents: 439
diff changeset
   661
#endif
claus
parents: 439
diff changeset
   662
claus
parents: 439
diff changeset
   663
#if defined(WANT_REALPATH)
406
claus
parents: 384
diff changeset
   664
claus
parents: 384
diff changeset
   665
# ifndef NULL
claus
parents: 384
diff changeset
   666
#  define NULL (char *)0
claus
parents: 384
diff changeset
   667
# endif
claus
parents: 384
diff changeset
   668
439
claus
parents: 438
diff changeset
   669
# define MAX_READLINKS 32
claus
parents: 438
diff changeset
   670
claus
parents: 438
diff changeset
   671
# ifndef MAXPATHLEN
claus
parents: 438
diff changeset
   672
#  define MAXPATHLEN     1024
claus
parents: 438
diff changeset
   673
# endif
406
claus
parents: 384
diff changeset
   674
claus
parents: 384
diff changeset
   675
static
claus
parents: 384
diff changeset
   676
char *realpath(path, resolved_path)
claus
parents: 384
diff changeset
   677
char *path;
claus
parents: 384
diff changeset
   678
char resolved_path [];
claus
parents: 384
diff changeset
   679
{
claus
parents: 384
diff changeset
   680
	char copy_path[MAXPATHLEN];
claus
parents: 384
diff changeset
   681
	char link_path[MAXPATHLEN];
claus
parents: 384
diff changeset
   682
	char *new_path = resolved_path;
claus
parents: 384
diff changeset
   683
	char *max_path;
claus
parents: 384
diff changeset
   684
	int readlinks = 0;
claus
parents: 384
diff changeset
   685
	int n;
claus
parents: 384
diff changeset
   686
claus
parents: 384
diff changeset
   687
	/* Make a copy of the source path since we may need to modify it. */
claus
parents: 384
diff changeset
   688
	strcpy(copy_path, path);
claus
parents: 384
diff changeset
   689
	path = copy_path;
claus
parents: 384
diff changeset
   690
	max_path = copy_path + MAXPATHLEN - 2;
claus
parents: 384
diff changeset
   691
	/* If it's a relative pathname use getwd for starters. */
claus
parents: 384
diff changeset
   692
	if (*path != '/') {
claus
parents: 384
diff changeset
   693
#ifdef HAS_GETCWD
claus
parents: 384
diff changeset
   694
		getcwd(new_path, MAXPATHLEN - 1);
claus
parents: 384
diff changeset
   695
#else
claus
parents: 384
diff changeset
   696
		getwd(new_path);
claus
parents: 384
diff changeset
   697
#endif
claus
parents: 384
diff changeset
   698
		new_path += strlen(new_path);
claus
parents: 384
diff changeset
   699
		if (new_path[-1] != '/')
claus
parents: 384
diff changeset
   700
			*new_path++ = '/';
claus
parents: 384
diff changeset
   701
	}
claus
parents: 384
diff changeset
   702
	else {
claus
parents: 384
diff changeset
   703
		*new_path++ = '/';
claus
parents: 384
diff changeset
   704
		path++;
claus
parents: 384
diff changeset
   705
	}
claus
parents: 384
diff changeset
   706
	/* Expand each slash-separated pathname component. */
claus
parents: 384
diff changeset
   707
	while (*path != '\0') {
claus
parents: 384
diff changeset
   708
		/* Ignore stray "/". */
claus
parents: 384
diff changeset
   709
		if (*path == '/') {
claus
parents: 384
diff changeset
   710
			path++;
claus
parents: 384
diff changeset
   711
			continue;
claus
parents: 384
diff changeset
   712
		}
claus
parents: 384
diff changeset
   713
		if (*path == '.') {
claus
parents: 384
diff changeset
   714
			/* Ignore ".". */
claus
parents: 384
diff changeset
   715
			if (path[1] == '\0' || path[1] == '/') {
claus
parents: 384
diff changeset
   716
				path++;
claus
parents: 384
diff changeset
   717
				continue;
claus
parents: 384
diff changeset
   718
			}
claus
parents: 384
diff changeset
   719
			if (path[1] == '.') {
claus
parents: 384
diff changeset
   720
				if (path[2] == '\0' || path[2] == '/') {
claus
parents: 384
diff changeset
   721
					path += 2;
claus
parents: 384
diff changeset
   722
					/* Ignore ".." at root. */
claus
parents: 384
diff changeset
   723
					if (new_path == resolved_path + 1)
claus
parents: 384
diff changeset
   724
						continue;
claus
parents: 384
diff changeset
   725
					/* Handle ".." by backing up. */
claus
parents: 384
diff changeset
   726
					while ((--new_path)[-1] != '/')
claus
parents: 384
diff changeset
   727
						;
claus
parents: 384
diff changeset
   728
					continue;
claus
parents: 384
diff changeset
   729
				}
claus
parents: 384
diff changeset
   730
			}
claus
parents: 384
diff changeset
   731
		}
claus
parents: 384
diff changeset
   732
		/* Safely copy the next pathname component. */
claus
parents: 384
diff changeset
   733
		while (*path != '\0' && *path != '/') {
claus
parents: 384
diff changeset
   734
			if (path > max_path) {
claus
parents: 384
diff changeset
   735
				errno = ENAMETOOLONG;
claus
parents: 384
diff changeset
   736
				return NULL;
claus
parents: 384
diff changeset
   737
			}
claus
parents: 384
diff changeset
   738
			*new_path++ = *path++;
claus
parents: 384
diff changeset
   739
		}
claus
parents: 384
diff changeset
   740
#ifdef S_IFLNK
claus
parents: 384
diff changeset
   741
		/* Protect against infinite loops. */
claus
parents: 384
diff changeset
   742
		if (readlinks++ > MAX_READLINKS) {
claus
parents: 384
diff changeset
   743
			errno = ELOOP;
claus
parents: 384
diff changeset
   744
			return NULL;
claus
parents: 384
diff changeset
   745
		}
claus
parents: 384
diff changeset
   746
		/* See if latest pathname component is a symlink. */
claus
parents: 384
diff changeset
   747
		*new_path = '\0';
claus
parents: 384
diff changeset
   748
		n = readlink(resolved_path, link_path, MAXPATHLEN - 1);
claus
parents: 384
diff changeset
   749
		if (n < 0) {
claus
parents: 384
diff changeset
   750
			/* EINVAL means the file exists but isn't a symlink. */
claus
parents: 384
diff changeset
   751
			if (errno != EINVAL)
claus
parents: 384
diff changeset
   752
				return NULL;
claus
parents: 384
diff changeset
   753
		}
claus
parents: 384
diff changeset
   754
		else {
claus
parents: 384
diff changeset
   755
			/* Note: readlink doesn't add the null byte. */
claus
parents: 384
diff changeset
   756
			link_path[n] = '\0';
claus
parents: 384
diff changeset
   757
			if (*link_path == '/')
claus
parents: 384
diff changeset
   758
				/* Start over for an absolute symlink. */
claus
parents: 384
diff changeset
   759
				new_path = resolved_path;
claus
parents: 384
diff changeset
   760
			else
claus
parents: 384
diff changeset
   761
				/* Otherwise back up over this component. */
claus
parents: 384
diff changeset
   762
				while (*(--new_path) != '/')
claus
parents: 384
diff changeset
   763
					;
claus
parents: 384
diff changeset
   764
			/* Safe sex check. */
claus
parents: 384
diff changeset
   765
			if (strlen(path) + n >= MAXPATHLEN) {
claus
parents: 384
diff changeset
   766
				errno = ENAMETOOLONG;
claus
parents: 384
diff changeset
   767
				return NULL;
claus
parents: 384
diff changeset
   768
			}
claus
parents: 384
diff changeset
   769
			/* Insert symlink contents into path. */
claus
parents: 384
diff changeset
   770
			strcat(link_path, path);
claus
parents: 384
diff changeset
   771
			strcpy(copy_path, link_path);
claus
parents: 384
diff changeset
   772
			path = copy_path;
claus
parents: 384
diff changeset
   773
		}
claus
parents: 384
diff changeset
   774
#endif /* S_IFLNK */
claus
parents: 384
diff changeset
   775
		*new_path++ = '/';
claus
parents: 384
diff changeset
   776
	}
claus
parents: 384
diff changeset
   777
	/* Delete trailing slash but don't whomp a lone slash. */
claus
parents: 384
diff changeset
   778
	if (new_path != resolved_path + 1 && new_path[-1] == '/')
claus
parents: 384
diff changeset
   779
		new_path--;
claus
parents: 384
diff changeset
   780
	/* Make sure it's null terminated. */
claus
parents: 384
diff changeset
   781
	*new_path = '\0';
claus
parents: 384
diff changeset
   782
	return resolved_path;
claus
parents: 384
diff changeset
   783
}
claus
parents: 384
diff changeset
   784
# define HAS_REALPATH
claus
parents: 384
diff changeset
   785
#endif /* WANT_REALPATH && not HAS_REALPATH */
claus
parents: 384
diff changeset
   786
%}
claus
parents: 384
diff changeset
   787
! !
claus
parents: 384
diff changeset
   788
1799
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
   789
!OperatingSystem class methodsFor:'documentation'!
2
claus
parents: 1
diff changeset
   790
88
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
   791
copyright
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
   792
"
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
   793
 COPYRIGHT (c) 1988 by Claus Gittinger
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
   794
	      All Rights Reserved
88
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
   795
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
   796
 This software is furnished under a license and may be used
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
   797
 only in accordance with the terms of that license and with the
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
   798
 inclusion of the above copyright notice.   This software may not
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
   799
 be provided or otherwise made available to, or used by, any
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
   800
 other person.  No title to or ownership of the software is
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
   801
 hereby transferred.
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
   802
"
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
   803
!
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
   804
2
claus
parents: 1
diff changeset
   805
documentation
claus
parents: 1
diff changeset
   806
"
530
07d0bce293c9 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 520
diff changeset
   807
    this class realizes access to most (all ?) required operating system services;
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
   808
    some of it is very specific for unix, so do not depend on
1619
2ce129068706 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1617
diff changeset
   809
    things available here in your applications 
2ce129068706 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1617
diff changeset
   810
    - some may not be found in other OS's or be slightly different ...
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
   811
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
   812
    (On the other hand: I do not want to hide all features
759
908363ce8a32 interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents: 756
diff changeset
   813
     from you - in some situations it MAY be interesting to be
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
   814
     able to get down to a select or fork system call easily (at least on Unix systems).
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
   815
     You decide - portability vs. functionality)
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
   816
1286
4270a0b4917d documentation
Claus Gittinger <cg@exept.de>
parents: 1280
diff changeset
   817
    [Class variables:]
4270a0b4917d documentation
Claus Gittinger <cg@exept.de>
parents: 1280
diff changeset
   818
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   819
	HostName        <String>        remembered hostname
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   820
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   821
	DomainName      <String>        remembered domainname
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   822
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   823
	LastErrorNumber <Integer>       the last value of errno
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   824
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   825
	OSSignals       <Array>         Array of signals to be raised for corresponding
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   826
					OperatingSystem signals.
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   827
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   828
	ForkFailed      <Boolean>       set if a fork (or popen) has failed;
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   829
					ST/X will avoid doing more forks/popens
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   830
					if this flag is set, for a slightly
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   831
					smoother operation.
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   832
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   833
	SlowFork        <Boolean>       if set, fork and popen are avoided;
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   834
					(more or less obsolete now)
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   835
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   836
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   837
	ErrorSignal     <Signal>        Parentsignal of all OS error signals.
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   838
					not directly raised.
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   839
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   840
	AccessDeniedErrorSignal
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   841
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   842
	FileNotFoundErrorSignal
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   843
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   844
	LocaleInfo      <Dictionary>    if non nil, that is taken instead of the operating
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   845
					systems locale definitions (allows for overwriting
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   846
					these, or provide a compatible info on systems which do
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   847
					not support locales)
1286
4270a0b4917d documentation
Claus Gittinger <cg@exept.de>
parents: 1280
diff changeset
   848
4270a0b4917d documentation
Claus Gittinger <cg@exept.de>
parents: 1280
diff changeset
   849
    [author:]
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   850
	Claus Gittinger
1286
4270a0b4917d documentation
Claus Gittinger <cg@exept.de>
parents: 1280
diff changeset
   851
4270a0b4917d documentation
Claus Gittinger <cg@exept.de>
parents: 1280
diff changeset
   852
    [see also:]
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   853
	OSProcessStatus
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   854
	Filename Date Time
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   855
	ExternalStream FileStream PipeStream Socket
2
claus
parents: 1
diff changeset
   856
"
1619
2ce129068706 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1617
diff changeset
   857
!
2ce129068706 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1617
diff changeset
   858
2ce129068706 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1617
diff changeset
   859
examples
2ce129068706 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1617
diff changeset
   860
"
1622
e40404e0a49d more examples
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   861
  various queries
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   862
								[exBegin]
1622
e40404e0a49d more examples
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   863
    Transcript 
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   864
	showCR:'hello ' , (OperatingSystem getLoginName)
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   865
								[exEnd]
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   866
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   867
								[exBegin]
1622
e40404e0a49d more examples
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   868
    OperatingSystem isUNIXlike ifTrue:[
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   869
	Transcript showCR:'this is some UNIX-like OS'
1622
e40404e0a49d more examples
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   870
    ] ifFalse:[
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   871
	Transcript showCR:'this OS is not UNIX-like'
1622
e40404e0a49d more examples
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   872
    ]
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   873
								[exEnd]
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   874
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   875
								[exBegin]
1622
e40404e0a49d more examples
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   876
    Transcript 
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   877
	showCR:'this machine is called ' , OperatingSystem getHostName
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   878
								[exEnd]
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   879
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   880
								[exBegin]
1622
e40404e0a49d more examples
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   881
    Transcript 
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   882
	showCR:('this machine is in the '
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   883
	       , OperatingSystem getDomainName
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   884
	       , ' domain')
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   885
								[exEnd]
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   886
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   887
								[exBegin]
1622
e40404e0a49d more examples
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   888
    Transcript 
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   889
	showCR:('this machine''s CPU is a '
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   890
	       , OperatingSystem getCPUType
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   891
	       )
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   892
								[exEnd]
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   893
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   894
								[exBegin]
1622
e40404e0a49d more examples
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   895
    Transcript showCR:'executing ls command ...'.
e40404e0a49d more examples
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   896
    OperatingSystem executeCommand:'ls'.
e40404e0a49d more examples
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   897
    Transcript showCR:'... done.'.
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   898
								[exEnd]
1622
e40404e0a49d more examples
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   899
1621
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
   900
  locking a file 
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
   901
  (should be executed on two running smalltalks - not in two threads):
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   902
								[exBegin]
1621
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
   903
    |f|
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
   904
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
   905
    f := 'testFile' asFilename readWriteStream.
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
   906
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
   907
    10 timesRepeat:[
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   908
	'about to lock ...' printCR.
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   909
	[
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   910
	  OperatingSystem 
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   911
	    lockFD:(f fileDescriptor)
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   912
	    shared:false
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   913
	    blocking:false
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   914
	] whileFalse:[
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   915
	    'process ' print. OperatingSystem getProcessId print. ' is waiting' printCR.
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   916
	    Delay waitForSeconds:1
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   917
	].
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   918
	'LOCKED ...' printCR.
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   919
	Delay waitForSeconds:10.
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   920
	'unlock ...' printCR.
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   921
	(OperatingSystem 
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   922
	    unlockFD:(f fileDescriptor)) printCR.
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   923
	Delay waitForSeconds:3.
1621
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
   924
    ]
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   925
								[exBegin]
1619
2ce129068706 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1617
diff changeset
   926
"
2
claus
parents: 1
diff changeset
   927
! !
claus
parents: 1
diff changeset
   928
1799
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
   929
!OperatingSystem class methodsFor:'initialization'!
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   930
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   931
initialize
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
   932
    "initialize the class"
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
   933
540
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
   934
    ObjectMemory addDependent:self.
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
   935
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
   936
    ErrorSignal isNil ifTrue:[
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
   937
	ErrorSignal := Object errorSignal newSignalMayProceed:true..
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
   938
	ErrorSignal nameClass:self message:#errorSignal.
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
   939
	ErrorSignal notifierString:'OS error encountered'.
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
   940
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
   941
	AccessDeniedErrorSignal := ErrorSignal newSignalMayProceed:true.
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
   942
	AccessDeniedErrorSignal nameClass:self message:#accessDeniedError.
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
   943
	AccessDeniedErrorSignal notifierString:'OS access denied'.
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
   944
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
   945
	FileNotFoundErrorSignal := ErrorSignal newSignalMayProceed:true.
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
   946
	FileNotFoundErrorSignal nameClass:self message:#fileNotFoundErrorSignal.
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
   947
	FileNotFoundErrorSignal notifierString:'OS file not found'.
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
   948
    ]
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   949
!
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   950
1470
266520246a88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1441
diff changeset
   951
update:something with:aParameter from:changedObject
1247
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
   952
    "catch image restart and flush some cached data"
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
   953
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   954
    something == #earlyRestart ifTrue:[
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   955
	"
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   956
	 flush cached data
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   957
	"
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   958
	HostName := nil.
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   959
	DomainName := nil.
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   960
	LastErrorNumber := nil.
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   961
    ]
1247
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
   962
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
   963
    "Modified: 22.4.1996 / 13:10:43 / cg"
1470
266520246a88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1441
diff changeset
   964
    "Created: 15.6.1996 / 15:22:37 / cg"
2080
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
   965
    "Modified: 7.1.1997 / 19:36:11 / stefan"
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   966
! !
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   967
1799
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
   968
!OperatingSystem class methodsFor:'OS signal constants'!
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   969
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   970
sigABRT
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   971
    "return the signal number for SIGABRT - 0 if not supported by OS
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   972
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   973
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   974
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   975
#ifdef SIGABRT
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
   976
    RETURN ( __MKSMALLINT(SIGABRT) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   977
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
   978
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   979
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   980
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   981
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   982
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   983
sigALRM
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   984
    "return the signal number for SIGALRM - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   985
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   986
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   987
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   988
#ifdef SIGALRM
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
   989
    RETURN ( __MKSMALLINT(SIGALRM) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   990
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
   991
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   992
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   993
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   994
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   995
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   996
sigBREAK
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   997
    "return the signal number for SIGBREAK - 0 if not supported.
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   998
     This is an MSDOS specific signal"
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   999
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1000
%{  /* NOCONTEXT */
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1001
#ifdef SIGBREAK
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1002
    RETURN ( __MKSMALLINT(SIGBREAK) );
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1003
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1004
    RETURN ( __MKSMALLINT(0) );
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1005
#endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1006
%}
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1007
!
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1008
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1009
sigBUS
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1010
    "return the signal number for SIGBUS - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1011
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1012
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1013
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1014
#ifdef SIGBUS
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1015
    RETURN ( __MKSMALLINT(SIGBUS) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1016
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1017
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1018
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1019
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1020
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1021
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1022
sigCHLD
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1023
    "return the signal number for SIGCHLD - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1024
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1025
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1026
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1027
#if defined(SIGCHLD)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1028
    RETURN ( __MKSMALLINT(SIGCHLD) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1029
#else
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1030
# if  defined(SIGCLD)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1031
    RETURN ( __MKSMALLINT(SIGCLD) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1032
# else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1033
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1034
# endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1035
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1036
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1037
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1038
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1039
sigCONT
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1040
    "return the signal number for SIGCONT - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1041
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1042
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1043
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1044
#if defined(SIGCONT)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1045
    RETURN ( __MKSMALLINT(SIGCONT) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1046
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1047
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1048
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1049
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1050
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1051
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1052
sigDANGER
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1053
    "return the signal number for SIGDANGER - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1054
     (seems to be an AIX special)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1055
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1056
%{  /* NOCONTEXT */
710
10d86ca4c4a6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 704
diff changeset
  1057
#if defined(SIGDANGER)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1058
    RETURN ( __MKSMALLINT(SIGDANGER) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1059
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1060
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1061
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1062
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1063
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1064
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1065
sigEMT
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1066
    "return the signal number for SIGEMT - 0 if not supported by OS
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1067
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1068
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1069
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1070
#ifdef SIGEMT
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1071
    RETURN ( __MKSMALLINT(SIGEMT) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1072
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1073
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1074
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1075
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1076
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1077
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1078
sigFP
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1079
    "return the signal number for SIGFP - 0 if not supported by OS
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1080
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1081
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1082
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1083
#ifdef SIGFPE
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1084
    RETURN ( __MKSMALLINT(SIGFPE) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1085
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1086
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1087
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1088
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1089
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1090
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1091
sigGRANT
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1092
    "return the signal number for SIGGRANT - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1093
     (seems to be an AIX special)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1094
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1095
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1096
#if defined(SIGGRANT)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1097
    RETURN ( __MKSMALLINT(SIGGRANT) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1098
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1099
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1100
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1101
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1102
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1103
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1104
sigHUP
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1105
    "return the signal number for SIGHUP
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1106
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1107
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1108
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1109
#ifdef SIGHUP
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1110
    RETURN ( __MKSMALLINT(SIGHUP) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1111
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1112
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1113
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1114
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1115
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1116
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1117
sigILL
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1118
    "return the signal number for SIGILL - 0 if not supported by OS
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1119
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1120
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1121
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1122
#ifdef SIGILL
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1123
    RETURN ( __MKSMALLINT(SIGILL) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1124
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1125
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1126
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1127
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1128
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1129
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1130
sigINT
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1131
    "return the signal number for SIGINT
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1132
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1133
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1134
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1135
#ifdef SIGINT
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1136
    RETURN ( __MKSMALLINT(SIGINT) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1137
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1138
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1139
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1140
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1141
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1142
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1143
sigIO
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1144
    "return the signal number for SIGIO - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1145
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1146
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1147
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1148
#if defined(SIGIO)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1149
    RETURN ( __MKSMALLINT(SIGIO) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1150
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1151
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1152
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1153
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1154
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1155
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1156
sigIOT
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1157
    "return the signal number for SIGIOT - 0 if not supported by OS
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1158
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1159
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1160
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1161
#ifdef SIGIOT
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1162
    RETURN ( __MKSMALLINT(SIGIOT) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1163
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1164
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1165
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1166
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1167
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1168
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1169
sigKILL
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1170
    "return the signal number for SIGKILL
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1171
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1172
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1173
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1174
#ifdef SIGKILL
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1175
    RETURN ( __MKSMALLINT(SIGKILL) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1176
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1177
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1178
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1179
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1180
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1181
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1182
sigLOST
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1183
    "return the signal number for SIGLOST - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1184
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1185
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1186
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1187
#if defined(SIGLOST)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1188
    RETURN ( __MKSMALLINT(SIGLOST) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1189
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1190
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1191
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1192
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1193
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1194
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1195
sigMIGRATE
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1196
    "return the signal number for SIGMIGRATE - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1197
     (seems to be an AIX special)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1198
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1199
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1200
#if defined(SIGMIGRATE)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1201
    RETURN ( __MKSMALLINT(SIGMIGRATE) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1202
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1203
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1204
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1205
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1206
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1207
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1208
sigMSG
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1209
    "return the signal number for SIGMSG - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1210
     (seems to be an AIX special)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1211
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1212
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1213
#if defined(SIGMSG)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1214
    RETURN ( __MKSMALLINT(SIGMSG) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1215
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1216
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1217
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1218
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1219
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1220
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1221
sigPIPE
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1222
    "return the signal number for SIGPIPE - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1223
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1224
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1225
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1226
#ifdef SIGPIPE
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1227
    RETURN ( __MKSMALLINT(SIGPIPE) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1228
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1229
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1230
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1231
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1232
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1233
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1234
sigPOLL
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1235
    "return the signal number for SIGPOLL - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1236
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1237
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1238
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1239
#if defined(SIGPOLL)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1240
    RETURN ( __MKSMALLINT(SIGPOLL) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1241
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1242
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1243
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1244
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1245
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1246
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1247
sigPRE
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1248
    "return the signal number for SIGPRE - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1249
     (seems to be an AIX special)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1250
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1251
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1252
#if defined(SIGPRE)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1253
    RETURN ( __MKSMALLINT(SIGPRE) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1254
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1255
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1256
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1257
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1258
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1259
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1260
sigPROF
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1261
    "return the signal number for SIGPROF - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1262
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1263
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1264
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1265
#if defined(SIGPROF)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1266
    RETURN ( __MKSMALLINT(SIGPROF) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1267
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1268
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1269
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1270
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1271
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1272
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1273
sigPWR
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1274
    "return the signal number for SIGPWR - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1275
     (not available on all systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1276
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1277
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1278
#if defined(SIGPWR)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1279
    RETURN ( __MKSMALLINT(SIGPWR) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1280
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1281
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1282
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1283
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1284
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1285
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1286
sigQUIT
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1287
    "return the signal number for SIGQUIT
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1288
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1289
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1290
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1291
#ifdef SIGQUIT
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1292
    RETURN ( __MKSMALLINT(SIGQUIT) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1293
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1294
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1295
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1296
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1297
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1298
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1299
sigRETRACT
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1300
    "return the signal number for SIGRETRACT - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1301
     (seems to be an AIX special)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1302
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1303
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1304
#if defined(SIGRETRACT)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1305
    RETURN ( __MKSMALLINT(SIGRETRACT) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1306
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1307
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1308
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1309
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1310
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1311
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1312
sigSAK
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1313
    "return the signal number for SIGSAK - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1314
     (seems to be an AIX special)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1315
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1316
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1317
#if defined(SIGSAK)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1318
    RETURN ( __MKSMALLINT(SIGSAK) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1319
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1320
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1321
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1322
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1323
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1324
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1325
sigSEGV
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1326
    "return the signal number for SIGSEGV - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1327
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1328
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1329
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1330
#ifdef SIGSEGV
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1331
    RETURN ( __MKSMALLINT(SIGSEGV) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1332
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1333
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1334
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1335
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1336
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1337
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1338
sigSOUND
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1339
    "return the signal number for SIGSOUND - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1340
     (seems to be an AIX special)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1341
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1342
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1343
#if defined(SIGSOUND)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1344
    RETURN ( __MKSMALLINT(SIGSOUND) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1345
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1346
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1347
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1348
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1349
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1350
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1351
sigSTOP
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1352
    "return the signal number for SIGSTOP - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1353
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1354
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1355
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1356
#if defined(SIGSTOP)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1357
    RETURN ( __MKSMALLINT(SIGSTOP) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1358
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1359
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1360
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1361
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1362
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1363
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1364
sigSYS
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1365
    "return the signal number for SIGSYS - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1366
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1367
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1368
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1369
#ifdef SIGSYS
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1370
    RETURN ( __MKSMALLINT(SIGSYS) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1371
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1372
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1373
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1374
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1375
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1376
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1377
sigTERM
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1378
    "return the signal number for SIGTERM - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1379
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1380
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1381
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1382
#ifdef SIGTERM
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1383
    RETURN ( __MKSMALLINT(SIGTERM) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1384
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1385
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1386
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1387
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1388
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1389
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1390
sigTRAP
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1391
    "return the signal number for SIGTRAP - 0 if not supported by OS
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1392
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1393
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1394
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1395
#ifdef SIGTRAP
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1396
    RETURN ( __MKSMALLINT(SIGTRAP) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1397
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1398
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1399
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1400
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1401
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1402
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1403
sigTSTP
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1404
    "return the signal number for SIGTSTP - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1405
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1406
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1407
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1408
#if defined(SIGTSTP)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1409
    RETURN ( __MKSMALLINT(SIGTSTP) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1410
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1411
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1412
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1413
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1414
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1415
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1416
sigTTIN
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1417
    "return the signal number for SIGTTIN - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1418
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1419
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1420
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1421
#if defined(SIGTTIN)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1422
    RETURN ( __MKSMALLINT(SIGTTIN) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1423
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1424
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1425
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1426
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1427
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1428
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1429
sigTTOU
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1430
    "return the signal number for SIGTTOU - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1431
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1432
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1433
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1434
#if defined(SIGTTOU)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1435
    RETURN ( __MKSMALLINT(SIGTTOU) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1436
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1437
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1438
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1439
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1440
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1441
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1442
sigURG
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1443
    "return the signal number for SIGURG - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1444
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1445
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1446
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1447
#if defined(SIGURG)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1448
    RETURN ( __MKSMALLINT(SIGURG) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1449
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1450
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1451
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1452
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1453
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1454
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1455
sigUSR1
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1456
    "return the signal number for SIGUSR1 - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1457
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1458
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1459
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1460
#if defined(SIGUSR1)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1461
    RETURN ( __MKSMALLINT(SIGUSR1) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1462
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1463
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1464
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1465
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1466
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1467
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1468
sigUSR2
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1469
    "return the signal number for SIGUSR2 - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1470
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1471
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1472
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1473
#if defined(SIGUSR2)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1474
    RETURN ( __MKSMALLINT(SIGUSR2) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1475
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1476
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1477
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1478
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1479
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1480
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1481
sigVTALRM
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1482
    "return the signal number for SIGVTALRM - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1483
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1484
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1485
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1486
#if defined(SIGVTALRM)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1487
    RETURN ( __MKSMALLINT(SIGVTALRM) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1488
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1489
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1490
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1491
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1492
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1493
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1494
sigWINCH
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1495
    "return the signal number for SIGWINCH - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1496
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1497
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1498
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1499
#if defined(SIGWINCH)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1500
    RETURN ( __MKSMALLINT(SIGWINCH) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1501
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1502
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1503
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1504
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1505
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1506
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1507
sigXCPU
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1508
    "return the signal number for SIGXCPU - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1509
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1510
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1511
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1512
#if defined(SIGXCPU)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1513
    RETURN ( __MKSMALLINT(SIGXCPU) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1514
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1515
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1516
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1517
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1518
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1519
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1520
sigXFSZ
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1521
    "return the signal number for SIGXFSZ - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1522
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1523
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1524
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1525
#if defined(SIGXFSZ)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1526
    RETURN ( __MKSMALLINT(SIGXFSZ) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1527
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1528
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1529
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1530
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1531
! !
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1532
1799
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  1533
!OperatingSystem class methodsFor:'Signal constants'!
540
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
  1534
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1535
accessDeniedErrorSignal
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1536
    "return the signal raised when a (file-) access is denied."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1537
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1538
    ^ AccessDeniedErrorSignal
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1539
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1540
540
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
  1541
errorSignal
1247
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
  1542
    "return the parent signal of all OS signals."
540
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
  1543
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
  1544
    ^ ErrorSignal
1247
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
  1545
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
  1546
    "Modified: 22.4.1996 / 13:11:31 / cg"
540
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
  1547
!
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
  1548
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
  1549
fileNotFoundErrorSignal
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
  1550
    "return the signal raised when a file was not found."
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
  1551
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
  1552
    ^ FileNotFoundErrorSignal
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
  1553
! !
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
  1554
1799
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  1555
!OperatingSystem class methodsFor:'error messages'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1556
1153
8119975c55ce Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents: 1142
diff changeset
  1557
clearLastErrorNumber
8119975c55ce Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents: 1142
diff changeset
  1558
    "return the last errors number.
8119975c55ce Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents: 1142
diff changeset
  1559
     See also: #lastErrorSymbol and #lastErrorString.
8119975c55ce Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents: 1142
diff changeset
  1560
     Notice: having a single error number is a bad idea in a multithreaded
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  1561
	     environment - this interface will change."
1153
8119975c55ce Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents: 1142
diff changeset
  1562
8119975c55ce Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents: 1142
diff changeset
  1563
    LastErrorNumber := nil.
8119975c55ce Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents: 1142
diff changeset
  1564
8119975c55ce Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents: 1142
diff changeset
  1565
     "
8119975c55ce Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents: 1142
diff changeset
  1566
      OperatingSystem clearLastErrorNumber
8119975c55ce Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents: 1142
diff changeset
  1567
     "
8119975c55ce Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents: 1142
diff changeset
  1568
8119975c55ce Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents: 1142
diff changeset
  1569
    "Created: 12.4.1996 / 09:28:58 / stefan"
8119975c55ce Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents: 1142
diff changeset
  1570
    "Modified: 12.4.1996 / 09:38:51 / stefan"
8119975c55ce Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents: 1142
diff changeset
  1571
!
8119975c55ce Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents: 1142
diff changeset
  1572
85
claus
parents: 77
diff changeset
  1573
currentErrorNumber
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  1574
    "returns the OS's last error nr (i.e. the value of errno).
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  1575
     Notice, that the value of this flag is only valid immediately
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  1576
     after the error occurred - it gets updated with every other
85
claus
parents: 77
diff changeset
  1577
     request to the OS.
claus
parents: 77
diff changeset
  1578
     Use lastErrorNumber - currentErrorNumber is invalidated by
claus
parents: 77
diff changeset
  1579
     many, many internal calls."
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  1580
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  1581
%{  /* NOCONTEXT */
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  1582
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1583
     RETURN ( __MKSMALLINT(errno) );
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  1584
%}
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  1585
     "
85
claus
parents: 77
diff changeset
  1586
      OperatingSystem currentErrorNumber
claus
parents: 77
diff changeset
  1587
     "
claus
parents: 77
diff changeset
  1588
!
claus
parents: 77
diff changeset
  1589
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1590
errorNumberFor:aSymbol
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1591
    "given a symbolic error, return the numeric;
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1592
     (i.e. errorNumberFor:#EBADF returns EBADF's value).
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1593
     Use this, since error numbers are really not standard across unix systems."
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1594
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1595
%{   /* NOCONTEXT */
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1596
    OBJ sym = aSymbol;
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1597
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1598
    /*
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1599
     * POSIX errnos - these should be defined
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1600
     */
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1601
#ifdef EPERM
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1602
    if (sym == @symbol(EPERM)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1603
	RETURN ( __MKSMALLINT(EPERM) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1604
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1605
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1606
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1607
#ifdef ENOENT
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1608
    if (sym == @symbol(ENOENT)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1609
	RETURN ( __MKSMALLINT(ENOENT) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1610
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1611
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1612
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1613
#ifdef ESRCH
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1614
    if (sym == @symbol(ESRCH)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1615
	RETURN ( __MKSMALLINT(ESRCH) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1616
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1617
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1618
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1619
#ifdef EINTR
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1620
    if (sym == @symbol(EINTR)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1621
	RETURN ( __MKSMALLINT(EINTR) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1622
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1623
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1624
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1625
#ifdef EIO
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1626
    if (sym == @symbol(EIO)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1627
	RETURN ( __MKSMALLINT(EIO) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1628
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1629
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1630
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1631
#ifdef ENXIO
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1632
    if (sym == @symbol(ENXIO)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1633
	RETURN ( __MKSMALLINT(ENXIO) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1634
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1635
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1636
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1637
#ifdef E2BIG
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1638
    if (sym == @symbol(E2BIG)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1639
	RETURN ( __MKSMALLINT(E2BIG) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1640
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1641
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1642
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1643
#ifdef ENOEXEC
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1644
    if (sym == @symbol(ENOEXEC)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1645
	RETURN ( __MKSMALLINT(ENOEXEC) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1646
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1647
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1648
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1649
#ifdef EBADF
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1650
    if (sym == @symbol(EBADF)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1651
	RETURN ( __MKSMALLINT(EBADF) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1652
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1653
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1654
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1655
#ifdef ECHILD
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1656
    if (sym == @symbol(ECHILD)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1657
	RETURN ( __MKSMALLINT(ECHILD) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1658
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1659
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1660
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1661
#if defined(EAGAIN)
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1662
    if (sym == @symbol(EAGAIN)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1663
	RETURN ( __MKSMALLINT(EAGAIN) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1664
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1665
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1666
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1667
#ifdef ENOMEM
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1668
    if (sym == @symbol(ENOMEM)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1669
	RETURN ( __MKSMALLINT(ENOMEM) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1670
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1671
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1672
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1673
#ifdef EACCES
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1674
    if (sym == @symbol(EACCES)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1675
	RETURN ( __MKSMALLINT(EACCES) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1676
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1677
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1678
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1679
#ifdef EFAULT
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1680
    if (sym == @symbol(EFAULT)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1681
	RETURN ( __MKSMALLINT(EFAULT) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1682
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1683
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1684
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1685
#ifdef EBUSY
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1686
    if (sym == @symbol(EBUSY)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1687
	RETURN ( __MKSMALLINT(EBUSY) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1688
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1689
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1690
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1691
#ifdef EXDEV
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1692
    if (sym == @symbol(EXDEV)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1693
	RETURN ( __MKSMALLINT(EXDEV) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1694
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1695
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1696
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1697
#ifdef ENODEV
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1698
    if (sym == @symbol(ENODEV)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1699
	RETURN ( __MKSMALLINT(ENODEV) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1700
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1701
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1702
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1703
#ifdef ENOTDIR
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1704
    if (sym == @symbol(ENOTDIR)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1705
	RETURN ( __MKSMALLINT(ENOTDIR) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1706
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1707
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1708
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1709
#ifdef EISDIR
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1710
    if (sym == @symbol(EISDIR)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1711
	RETURN ( __MKSMALLINT(EISDIR) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1712
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1713
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1714
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1715
#ifdef EINVAL
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1716
    if (sym == @symbol(EINVAL)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1717
	RETURN ( __MKSMALLINT(EINVAL) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1718
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1719
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1720
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1721
#ifdef ENFILE
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1722
    if (sym == @symbol(ENFILE)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1723
	RETURN ( __MKSMALLINT(ENFILE) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1724
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1725
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1726
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1727
#ifdef EMFILE
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1728
    if (sym == @symbol(EMFILE)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1729
	RETURN ( __MKSMALLINT(EMFILE) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1730
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1731
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1732
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1733
#ifdef ENOTTY
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1734
    if (sym == @symbol(ENOTTY)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1735
	RETURN ( __MKSMALLINT(ENOTTY) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1736
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1737
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1738
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1739
#ifdef EFBIG
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1740
    if (sym == @symbol(EFBIG)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1741
	RETURN ( __MKSMALLINT(EFBIG) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1742
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1743
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1744
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1745
#ifdef ENOSPC
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1746
    if (sym == @symbol(ENOSPC)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1747
	RETURN ( __MKSMALLINT(ENOSPC) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1748
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1749
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1750
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1751
#ifdef ESPIPE
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1752
    if (sym == @symbol(ESPIPE)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1753
	RETURN ( __MKSMALLINT(ESPIPE) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1754
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1755
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1756
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1757
#ifdef EROFS
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1758
    if (sym == @symbol(EROFS)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1759
	RETURN ( __MKSMALLINT(EROFS) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1760
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1761
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1762
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1763
#ifdef EMLINK
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1764
    if (sym == @symbol(EMLINK)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1765
	RETURN ( __MKSMALLINT(EMLINK) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1766
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1767
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1768
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1769
#ifdef EPIPE
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1770
    if (sym == @symbol(EPIPE)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1771
	RETURN ( __MKSMALLINT(EPIPE) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1772
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1773
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1774
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1775
#ifdef EDOM
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1776
    if (sym == @symbol(EDOM)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1777
	RETURN ( __MKSMALLINT(EDOM) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1778
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1779
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1780
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1781
#ifdef ERANGE
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1782
    if (sym == @symbol(ERANGE)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1783
	RETURN ( __MKSMALLINT(ERANGE) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1784
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1785
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1786
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1787
#ifdef EDEADLK
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1788
    if (sym == @symbol(EDEADLK)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1789
	RETURN ( __MKSMALLINT(EDEADLK) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1790
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1791
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1792
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1793
#ifdef ENAMETOOLONG
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1794
    if (sym == @symbol(ENAMETOOLONG)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1795
	RETURN ( __MKSMALLINT(ENAMETOOLONG) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1796
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1797
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1798
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1799
#ifdef ENOLCK
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1800
    if (sym == @symbol(ENOLCK)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1801
	RETURN ( __MKSMALLINT(ENOLCK) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1802
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1803
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1804
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1805
#ifdef ENOSYS
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1806
    if (sym == @symbol(ENOSYS)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1807
	RETURN ( __MKSMALLINT(ENOSYS) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1808
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1809
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1810
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1811
#ifdef ENOTEMPTY
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1812
    if (sym == @symbol(ENOTEMPTY)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1813
	RETURN ( __MKSMALLINT(ENOTEMPTY) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1814
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1815
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1816
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1817
#ifdef EEXIST
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1818
    if (sym == @symbol(EEXIST)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1819
	RETURN ( __MKSMALLINT(EEXIST) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1820
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1821
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1822
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1823
#ifdef EILSEQ
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1824
    if (sym == @symbol(EILSEQ)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1825
	RETURN ( __MKSMALLINT(EILSEQ) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1826
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1827
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1828
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1829
    /*
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1830
     * XPG3 errnos - defined on most systems
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1831
     */
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1832
#ifdef ENOTBLK
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1833
    if (sym == @symbol(ENOTBLK)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1834
	RETURN ( __MKSMALLINT(ENOTBLK) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1835
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1836
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1837
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1838
#ifdef ETXTBSY
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1839
    if (sym == @symbol(ETXTBSY)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1840
	RETURN ( __MKSMALLINT(ETXTBSY) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1841
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1842
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1843
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1844
    /*
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1845
     * some others
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1846
     */
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1847
#ifdef EWOULDBLOCK
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1848
    if (sym == @symbol(EWOULDBLOCK)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1849
	RETURN ( __MKSMALLINT(EWOULDBLOCK) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1850
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1851
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1852
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1853
#ifdef ENOMSG
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1854
    if (sym == @symbol(ENOMSG)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1855
	RETURN ( __MKSMALLINT(ENOMSG) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1856
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1857
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1858
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1859
#ifdef ELOOP
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1860
    if (sym == @symbol(ELOOP)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1861
	RETURN ( __MKSMALLINT(ELOOP) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1862
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1863
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1864
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1865
    /*
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1866
     * some stream errors
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1867
     */
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1868
#ifdef ETIME
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1869
    if (sym == @symbol(ETIME)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1870
	RETURN ( __MKSMALLINT(ETIME) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1871
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1872
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1873
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1874
#ifdef ENOSR
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1875
    if (sym == @symbol(ENOSR)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1876
	RETURN ( __MKSMALLINT(ENOSR) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1877
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1878
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1879
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1880
#ifdef ENOSTR
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1881
    if (sym == @symbol(ENOSTR)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1882
	RETURN ( __MKSMALLINT(ENOSTR) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1883
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1884
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1885
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1886
#ifdef ECOMM
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1887
    if (sym == @symbol(ECOMM)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1888
	RETURN ( __MKSMALLINT(ECOMM) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1889
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1890
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1891
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1892
#ifdef EPROTO
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1893
    if (sym == @symbol(EPROTO)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1894
	RETURN ( __MKSMALLINT(EPROTO) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1895
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1896
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1897
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1898
    /*
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1899
     * nfs errors
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1900
     */
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1901
#ifdef ESTALE
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1902
    if (sym == @symbol(ESTALE)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1903
	RETURN ( __MKSMALLINT(ESTALE) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1904
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1905
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1906
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1907
#ifdef EREMOTE
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1908
    if (sym == @symbol(EREMOTE)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1909
	RETURN ( __MKSMALLINT(EREMOTE) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1910
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1911
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1912
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1913
    /*
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1914
     * some networking errors
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1915
     */
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1916
#ifdef EINPROGRESS
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1917
    if (sym == @symbol(EINPROGRESS)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1918
	RETURN ( __MKSMALLINT(EINPROGRESS) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1919
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1920
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1921
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1922
#ifdef EALREADY
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1923
    if (sym == @symbol(EALREADY)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1924
	RETURN ( __MKSMALLINT(EALREADY) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1925
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1926
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1927
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1928
#ifdef ENOTSOCK
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1929
    if (sym == @symbol(ENOTSOCK)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1930
	RETURN ( __MKSMALLINT(ENOTSOCK) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1931
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1932
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1933
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1934
#ifdef EDESTADDRREQ
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1935
    if (sym == @symbol(EDESTADDRREQ)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1936
	RETURN ( __MKSMALLINT(EDESTADDRREQ) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1937
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1938
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1939
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1940
#ifdef EMSGSIZE
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1941
    if (sym == @symbol(EMSGSIZE)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1942
	RETURN ( __MKSMALLINT(EMSGSIZE) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1943
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1944
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1945
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1946
#ifdef EPROTOTYPE
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1947
    if (sym == @symbol(EPROTOTYPE)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1948
	RETURN ( __MKSMALLINT(EPROTOTYPE) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1949
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1950
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1951
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1952
#ifdef ENOPROTOOPT
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1953
    if (sym == @symbol(ENOPROTOOPT)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1954
	RETURN ( __MKSMALLINT(ENOPROTOOPT) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1955
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1956
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1957
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1958
#ifdef EPROTONOSUPPORT
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1959
    if (sym == @symbol(EPROTONOSUPPORT)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1960
	RETURN ( __MKSMALLINT(EPROTONOSUPPORT) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1961
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1962
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1963
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1964
#ifdef ESOCKTNOSUPPORT
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1965
    if (sym == @symbol(ESOCKTNOSUPPORT)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1966
	RETURN ( __MKSMALLINT(ESOCKTNOSUPPORT) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1967
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1968
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1969
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1970
#ifdef EOPNOTSUPP
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1971
    if (sym == @symbol(EOPNOTSUPP)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1972
	RETURN ( __MKSMALLINT(EOPNOTSUPP) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1973
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1974
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1975
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1976
#ifdef EPFNOSUPPORT
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1977
    if (sym == @symbol(EPFNOSUPPORT)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1978
	RETURN ( __MKSMALLINT(EPFNOSUPPORT) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1979
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1980
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1981
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1982
#ifdef EAFNOSUPPORT
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1983
    if (sym == @symbol(EAFNOSUPPORT)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1984
	RETURN ( __MKSMALLINT(EAFNOSUPPORT) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1985
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1986
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1987
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1988
#ifdef EADDRINUSE
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1989
    if (sym == @symbol(EADDRINUSE)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1990
	RETURN ( __MKSMALLINT(EADDRINUSE) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1991
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1992
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1993
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1994
#ifdef EADDRNOTAVAIL
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1995
    if (sym == @symbol(EADDRNOTAVAIL)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1996
	RETURN ( __MKSMALLINT(EADDRNOTAVAIL) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1997
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1998
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1999
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2000
#ifdef ETIMEDOUT
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  2001
    if (sym == @symbol(ETIMEDOUT)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2002
	RETURN ( __MKSMALLINT(ETIMEDOUT) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2003
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2004
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2005
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2006
#ifdef ECONNREFUSED
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  2007
    if (sym == @symbol(ECONNREFUSED)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2008
	RETURN ( __MKSMALLINT(ECONNREFUSED) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2009
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2010
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2011
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2012
#ifdef ENETDOWN
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  2013
    if (sym == @symbol(ENETDOWN)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2014
	RETURN ( __MKSMALLINT(ENETDOWN) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2015
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2016
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2017
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2018
#ifdef ENETUNREACH
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  2019
    if (sym == @symbol(ENETUNREACH)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2020
	RETURN ( __MKSMALLINT(ENETUNREACH) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2021
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2022
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2023
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2024
#ifdef ENETRESET
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  2025
    if (sym == @symbol(ENETRESET)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2026
	RETURN ( __MKSMALLINT(ENETRESET) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2027
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2028
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2029
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2030
#ifdef ECONNABORTED
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  2031
    if (sym == @symbol(ECONNABORTED)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2032
	RETURN ( __MKSMALLINT(ECONNABORTED) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2033
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2034
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2035
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2036
#ifdef ECONNRESET
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  2037
    if (sym == @symbol(ECONNRESET)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2038
	RETURN ( __MKSMALLINT(ECONNRESET) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2039
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2040
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2041
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2042
#ifdef EISCONN
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  2043
    if (sym == @symbol(EISCONN)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2044
	RETURN ( __MKSMALLINT(EISCONN) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2045
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2046
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2047
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2048
#ifdef ENOTCONN
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  2049
    if (sym == @symbol(ENOTCONN)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2050
	RETURN ( __MKSMALLINT(ENOTCONN) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2051
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2052
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2053
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2054
#ifdef ESHUTDOWN
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  2055
    if (sym == @symbol(ESHUTDOWN)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2056
	RETURN ( __MKSMALLINT(ESHUTDOWN) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2057
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2058
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2059
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2060
#ifdef EHOSTDOWN
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  2061
    if (sym == @symbol(EHOSTDOWN)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2062
	RETURN ( __MKSMALLINT(EHOSTDOWN) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2063
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2064
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2065
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2066
#ifdef EHOSTUNREACH
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  2067
    if (sym == @symbol(EHOSTUNREACH)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2068
	RETURN ( __MKSMALLINT(EHOSTUNREACH) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2069
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2070
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2071
%}.
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2072
    ^ -1
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2073
!
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2074
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2075
errorSymbolAndTextForNumber:errNr
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2076
    "return an array consisting of symbol &  message string from a unix errorNumber 
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2077
     (as returned by a system call). 
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2078
     The returned message is in english (as found in /usr/include/errno.h)
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2079
     and should be replaced by a resource lookup before being presented to the user."
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2080
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2081
    |sym text|
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2082
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2083
%{
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2084
    /* claus:
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2085
     * I made this some primitive code, since errnos are not
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2086
     * standard across unixes
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2087
     */
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2088
    char *msg = "unknown error";
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2089
    char buffer[50];
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  2090
    OBJ eno = errNr;
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  2091
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  2092
    if (__isSmallInteger(eno)) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  2093
	switch (__intVal(eno)) {
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2094
	    /*
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2095
	     * POSIX errnos - these should be defined
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2096
	     */
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2097
#ifdef EPERM
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2098
	    case EPERM:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2099
		msg = "Operation not permitted";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2100
		sym = @symbol(EPERM);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2101
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2102
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2103
#ifdef ENOENT
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2104
	    case ENOENT:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2105
		msg = "No such file or directory";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2106
		sym = @symbol(ENOENT);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2107
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2108
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2109
#ifdef ESRCH
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2110
	    case ESRCH:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2111
		msg = "No such process";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2112
		sym = @symbol(ESRCH);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2113
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2114
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2115
#ifdef EINTR
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2116
	    case EINTR:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2117
		msg = "Interrupted system call";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2118
		sym = @symbol(EINTR);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2119
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2120
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2121
#ifdef EIO
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2122
	    case EIO:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2123
		msg = "I/O error";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2124
		sym = @symbol(EIO);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2125
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2126
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2127
#ifdef ENXIO
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2128
	    case ENXIO:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2129
		msg = "No such device or address";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2130
		sym = @symbol(ENXIO);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2131
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2132
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2133
#ifdef E2BIG
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2134
	    case E2BIG:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2135
		msg = "Arg list too long";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2136
		sym = @symbol(E2BIG);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2137
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2138
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2139
#ifdef ENOEXEC
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2140
	    case ENOEXEC:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2141
		msg = "Exec format error";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2142
		sym = @symbol(ENOEXEC);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2143
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2144
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2145
#ifdef EBADF
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2146
	    case EBADF:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2147
		msg = "Bad file number";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2148
		sym = @symbol(EBADF);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2149
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2150
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2151
#ifdef ECHILD
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2152
	    case ECHILD:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2153
		msg = "No child processes";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2154
		sym = @symbol(ECHILD);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2155
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2156
#endif
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2157
#if !defined(EWOULDBLOCK) && defined(EAGAIN) && (EWOULDBLOCK != EAGAIN)
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2158
	    case EAGAIN:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2159
		msg = "Try again";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2160
		sym = @symbol(EAGAIN);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2161
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2162
#endif
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2163
#ifdef ENOMEM
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2164
	    case ENOMEM:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2165
		msg = "Out of memory";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2166
		sym = @symbol(ENOMEM);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2167
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2168
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2169
#ifdef EACCES
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2170
	    case EACCES:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2171
		msg = "Permission denied";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2172
		sym = @symbol(EACCES);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2173
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2174
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2175
#ifdef EFAULT
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2176
	    case EFAULT:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2177
		msg = "Bad address";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2178
		sym = @symbol(EFAULT);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2179
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2180
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2181
#ifdef EBUSY
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2182
	    case EBUSY:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2183
		msg = "Device or resource busy";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2184
		sym = @symbol(EBUSY);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2185
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2186
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2187
#ifdef EEXIST
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2188
	    case EEXIST:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2189
		msg = "File exists";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2190
		sym = @symbol(EEXIST);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2191
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2192
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2193
#ifdef EXDEV
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2194
	    case EXDEV:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2195
		msg = "Cross-device link";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2196
		sym = @symbol(EXDEV);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2197
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2198
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2199
#ifdef ENODEV
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2200
	    case ENODEV:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2201
		msg = "No such device";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2202
		sym = @symbol(ENODEV);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2203
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2204
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2205
#ifdef ENOTDIR
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2206
	    case ENOTDIR:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2207
		msg = "Not a directory";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2208
		sym = @symbol(ENOTDIR);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2209
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2210
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2211
#ifdef EISDIR
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2212
	    case EISDIR:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2213
		msg = "Is a directory";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2214
		sym = @symbol(EISDIR);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2215
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2216
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2217
#ifdef EINVAL
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2218
	    case EINVAL:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2219
		msg = "Invalid argument";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2220
		sym = @symbol(EINVAL);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2221
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2222
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2223
#ifdef ENFILE
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2224
	    case ENFILE:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2225
		msg = "File table overflow";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2226
		sym = @symbol(ENFILE);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2227
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2228
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2229
#ifdef EMFILE
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2230
	    case EMFILE:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2231
		msg = "Too many open files";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2232
		sym = @symbol(EMFILE);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2233
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2234
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2235
#ifdef ENOTTY
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2236
	    case ENOTTY:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2237
		msg = "Not a typewriter";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2238
		sym = @symbol(ENOTTY);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2239
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2240
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2241
#ifdef EFBIG
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2242
	    case EFBIG:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2243
		msg = "File too large";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2244
		sym = @symbol(EFBIG);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2245
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2246
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2247
#ifdef ENOSPC
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2248
	    case ENOSPC:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2249
		msg = "No space left on device";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2250
		sym = @symbol(ENOSPC);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2251
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2252
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2253
#ifdef ESPIPE
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2254
	    case ESPIPE:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2255
		msg = "Illegal seek";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2256
		sym = @symbol(ESPIPE);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2257
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2258
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2259
#ifdef EROFS
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2260
	    case EROFS:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2261
		msg = "Read-only file system";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2262
		sym = @symbol(EROFS);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2263
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2264
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2265
#ifdef EMLINK
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2266
	    case EMLINK:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2267
		msg = "Too many links";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2268
		sym = @symbol(EMLINK);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2269
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2270
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2271
#ifdef EPIPE
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2272
	    case EPIPE:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2273
		msg = "Broken pipe";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2274
		sym = @symbol(EPIPE);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2275
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2276
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2277
#ifdef EDOM
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2278
	    case EDOM:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2279
		msg = "Math argument out of domain";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2280
		sym = @symbol(EDOM);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2281
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2282
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2283
#ifdef ERANGE
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2284
	    case ERANGE:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2285
		msg = "Math result not representable";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2286
		sym = @symbol(ERANGE);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2287
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2288
#endif
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2289
#ifdef EDEADLK
308
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  2290
# if EDEADLK != EWOULDBLOCK
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2291
	    case EDEADLK:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2292
		msg = "Resource deadlock would occur";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2293
		sym = @symbol(EDEADLK);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2294
		break;
308
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  2295
# endif
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2296
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2297
#ifdef ENAMETOOLONG
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2298
	    case ENAMETOOLONG:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2299
		msg = "File name too long";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2300
		sym = @symbol(ENAMETOOLONG);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2301
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2302
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2303
#ifdef ENOLCK
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2304
	    case ENOLCK:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2305
		msg = "No record locks available";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2306
		sym = @symbol(ENOLCK);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2307
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2308
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2309
#ifdef ENOSYS
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2310
	    case ENOSYS:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2311
		msg = "Function not implemented";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2312
		sym = @symbol(ENOSYS);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2313
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2314
#endif
359
claus
parents: 357
diff changeset
  2315
#if defined(ENOTEMPTY) && (ENOTEMPTY != EEXIST)
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2316
	    case ENOTEMPTY:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2317
		msg = "Directory not empty";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2318
		sym = @symbol(ENOTEMPTY);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2319
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2320
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2321
#ifdef EILSEQ
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2322
	    case EILSEQ:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2323
		msg = "Illegal byte sequence";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2324
		sym = @symbol(EILSEQ);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2325
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2326
#endif
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2327
	    /*
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2328
	     * XPG3 errnos - defined on most systems
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2329
	     */
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2330
#ifdef ENOTBLK
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2331
	    case ENOTBLK:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2332
		msg = "Block device required";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2333
		sym = @symbol(ENOTBLK);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2334
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2335
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2336
#ifdef ETXTBSY
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2337
	    case ETXTBSY:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2338
		msg = "Text file busy";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2339
		sym = @symbol(ETXTBSY);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2340
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2341
#endif
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2342
	    /*
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2343
	     * some others
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2344
	     */
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2345
#ifdef EWOULDBLOCK
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2346
	    case EWOULDBLOCK:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2347
		msg = "Operation would block";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2348
		sym = @symbol(EWOULDBLOCK);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2349
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2350
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2351
#ifdef ENOMSG
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2352
	    case ENOMSG:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2353
		msg = "No message of desired type";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2354
		sym = @symbol(ENOMSG);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2355
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2356
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2357
#ifdef ELOOP
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2358
	    case ELOOP:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2359
		msg = "Too many levels of symbolic links";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2360
		sym = @symbol(ELOOP);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2361
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2362
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2363
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2364
	    /*
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2365
	     * some stream errors
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2366
	     */
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2367
#ifdef ETIME
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2368
	    case ETIME:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2369
		msg = "Timer expired";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2370
		sym = @symbol(ETIME);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2371
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2372
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2373
#ifdef ENOSR
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2374
	    case ENOSR:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2375
		msg = "Out of streams resources";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2376
		sym = @symbol(ENOSR);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2377
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2378
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2379
#ifdef ENOSTR
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2380
	    case ENOSTR:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2381
		msg = "Device not a stream";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2382
		sym = @symbol(ENOSTR);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2383
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2384
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2385
#ifdef ECOMM
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2386
	    case ECOMM:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2387
		msg = "Communication error on send";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2388
		sym = @symbol(ECOMM);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2389
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2390
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2391
#ifdef EPROTO
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2392
	    case EPROTO:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2393
		msg = "Protocol error";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2394
		sym = @symbol(EPROTO);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2395
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2396
#endif
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2397
	    /*
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2398
	     * nfs errors
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2399
	     */
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2400
#ifdef ESTALE
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2401
	    case ESTALE:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2402
		msg = "Stale NFS file handle";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2403
		sym = @symbol(ESTALE);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2404
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2405
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2406
#ifdef EREMOTE
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2407
	    case EREMOTE:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2408
		msg = "Too many levels of remote in path";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2409
		sym = @symbol(EREMOTE);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2410
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2411
#endif
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2412
	    /*
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2413
	     * some networking errors
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2414
	     */
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2415
#ifdef EINPROGRESS
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2416
	    case EINPROGRESS:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2417
		msg = "Operation now in progress";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2418
		sym = @symbol(EINPROGRESS);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2419
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2420
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2421
#ifdef EALREADY
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2422
	    case EALREADY:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2423
		msg = "Operation already in progress";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2424
		sym = @symbol(EALREADY);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2425
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2426
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2427
#ifdef ENOTSOCK
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2428
	    case ENOTSOCK:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2429
		msg = "Socket operation on non-socket";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2430
		sym = @symbol(ENOTSOCK);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2431
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2432
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2433
#ifdef EDESTADDRREQ
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2434
	    case EDESTADDRREQ:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2435
		msg = "Destination address required";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2436
		sym = @symbol(EDESTADDRREQ);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2437
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2438
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2439
#ifdef EMSGSIZE
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2440
	    case EMSGSIZE:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2441
		msg = "Message too long";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2442
		sym = @symbol(EMSGSIZE);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2443
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2444
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2445
#ifdef EPROTOTYPE
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2446
	    case EPROTOTYPE:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2447
		msg = "Protocol wrong type for socket";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2448
		sym = @symbol(EPROTOTYPE);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2449
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2450
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2451
#ifdef ENOPROTOOPT
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2452
	    case ENOPROTOOPT:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2453
		msg = "Protocol not available";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2454
		sym = @symbol(ENOPROTOOPT);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2455
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2456
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2457
#ifdef EPROTONOSUPPORT
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2458
	    case EPROTONOSUPPORT:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2459
		msg = "Protocol not supported";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2460
		sym = @symbol(EPROTONOSUPPORT);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2461
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2462
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2463
#ifdef ESOCKTNOSUPPORT
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2464
	    case ESOCKTNOSUPPORT:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2465
		msg = "Socket type not supported";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2466
		sym = @symbol(ESOCKTNOSUPPORT);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2467
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2468
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2469
#ifdef EOPNOTSUPP
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2470
	    case EOPNOTSUPP:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2471
		msg = "Operation not supported on socket";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2472
		sym = @symbol(EOPNOTSUPP);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2473
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2474
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2475
#ifdef EPFNOSUPPORT
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2476
	    case EPFNOSUPPORT:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2477
		msg = "Protocol family not supported";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2478
		sym = @symbol(EPFNOSUPPORT);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2479
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2480
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2481
#ifdef EAFNOSUPPORT
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2482
	    case EAFNOSUPPORT:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2483
		msg = "Address family not supported by protocol family";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2484
		sym = @symbol(EAFNOSUPPORT);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2485
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2486
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2487
#ifdef EADDRINUSE
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2488
	    case EADDRINUSE:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2489
		msg = "Address already in use";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2490
		sym = @symbol(EADDRINUSE);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2491
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2492
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2493
#ifdef EADDRNOTAVAIL
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2494
	    case EADDRNOTAVAIL:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2495
		msg = "Can\'t assign requested address";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2496
		sym = @symbol(EADDRNOTAVAIL);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2497
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2498
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2499
#ifdef ETIMEDOUT
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2500
	    case ETIMEDOUT:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2501
		msg = "Connection timed out";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2502
		sym = @symbol(ETIMEDOUT);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2503
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2504
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2505
#ifdef ECONNREFUSED
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2506
	    case ECONNREFUSED:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2507
		msg = "Connection refused";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2508
		sym = @symbol(ECONNREFUSED);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2509
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2510
#endif
362
claus
parents: 359
diff changeset
  2511
#ifdef ENETDOWN
claus
parents: 359
diff changeset
  2512
	    case ENETDOWN:
claus
parents: 359
diff changeset
  2513
		msg = "Network is down";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2514
		sym = @symbol(ENETDOWN);
362
claus
parents: 359
diff changeset
  2515
		break;
claus
parents: 359
diff changeset
  2516
#endif
claus
parents: 359
diff changeset
  2517
#ifdef ENETUNREACH
claus
parents: 359
diff changeset
  2518
	    case ENETUNREACH:
claus
parents: 359
diff changeset
  2519
		msg = "Network is unreachable";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2520
		sym = @symbol(ENETUNREACH);
362
claus
parents: 359
diff changeset
  2521
		break;
claus
parents: 359
diff changeset
  2522
#endif
claus
parents: 359
diff changeset
  2523
#ifdef ENETRESET
claus
parents: 359
diff changeset
  2524
	    case ENETRESET:
claus
parents: 359
diff changeset
  2525
		msg = "Network dropped conn due to reset";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2526
		sym = @symbol(ENETRESET);
362
claus
parents: 359
diff changeset
  2527
		break;
claus
parents: 359
diff changeset
  2528
#endif
claus
parents: 359
diff changeset
  2529
#ifdef ECONNABORTED
claus
parents: 359
diff changeset
  2530
	    case ECONNABORTED:
claus
parents: 359
diff changeset
  2531
		msg = "Software caused connection abort";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2532
		sym = @symbol(ECONNABORTED);
362
claus
parents: 359
diff changeset
  2533
		break;
claus
parents: 359
diff changeset
  2534
#endif
claus
parents: 359
diff changeset
  2535
#ifdef ECONNRESET
claus
parents: 359
diff changeset
  2536
	    case ECONNRESET:
claus
parents: 359
diff changeset
  2537
		msg = "Connection reset by peer";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2538
		sym = @symbol(ECONNRESET);
362
claus
parents: 359
diff changeset
  2539
		break;
claus
parents: 359
diff changeset
  2540
#endif
claus
parents: 359
diff changeset
  2541
#ifdef EISCONN
claus
parents: 359
diff changeset
  2542
	    case EISCONN:
claus
parents: 359
diff changeset
  2543
		msg = "Socket is already connected";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2544
		sym = @symbol(EISCONN);
362
claus
parents: 359
diff changeset
  2545
		break;
claus
parents: 359
diff changeset
  2546
#endif
claus
parents: 359
diff changeset
  2547
#ifdef ENOTCONN
claus
parents: 359
diff changeset
  2548
	    case ENOTCONN:
claus
parents: 359
diff changeset
  2549
		msg = "Socket is not connected";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2550
		sym = @symbol(ENOTCONN);
362
claus
parents: 359
diff changeset
  2551
		break;
claus
parents: 359
diff changeset
  2552
#endif
claus
parents: 359
diff changeset
  2553
#ifdef ESHUTDOWN
claus
parents: 359
diff changeset
  2554
	    case ESHUTDOWN:
claus
parents: 359
diff changeset
  2555
		msg = "Can't send after socket shutdown";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2556
		sym = @symbol(ESHUTDOWN);
362
claus
parents: 359
diff changeset
  2557
		break;
claus
parents: 359
diff changeset
  2558
#endif
claus
parents: 359
diff changeset
  2559
#ifdef EHOSTDOWN
claus
parents: 359
diff changeset
  2560
	    case EHOSTDOWN:
claus
parents: 359
diff changeset
  2561
		msg = "Host is down";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2562
		sym = @symbol(EHOSTDOWN);
362
claus
parents: 359
diff changeset
  2563
		break;
claus
parents: 359
diff changeset
  2564
#endif
claus
parents: 359
diff changeset
  2565
#ifdef EHOSTUNREACH
claus
parents: 359
diff changeset
  2566
	    case EHOSTUNREACH:
claus
parents: 359
diff changeset
  2567
		msg = "No route to host";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2568
		sym = @symbol(EHOSTUNREACH);
362
claus
parents: 359
diff changeset
  2569
		break;
claus
parents: 359
diff changeset
  2570
#endif
claus
parents: 359
diff changeset
  2571
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2572
	    default:
368
a3c21a89ec37 *** empty log message ***
claus
parents: 362
diff changeset
  2573
		{
809
5eef87c2907b e convenient macro for register saving (sparc only)
Claus Gittinger <cg@exept.de>
parents: 805
diff changeset
  2574
		    __BEGIN_PROTECT_REGISTERS__
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  2575
		    sprintf(buffer, "ErrorNr: %d", __intVal(eno));
809
5eef87c2907b e convenient macro for register saving (sparc only)
Claus Gittinger <cg@exept.de>
parents: 805
diff changeset
  2576
		    __END_PROTECT_REGISTERS__
368
a3c21a89ec37 *** empty log message ***
claus
parents: 362
diff changeset
  2577
		}
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2578
		msg = buffer;
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2579
		break;
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2580
	}
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2581
    }
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2582
    text = __MKSTRING(msg);
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2583
%}.
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2584
    ^ Array with:sym with:text
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2585
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2586
    "
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2587
     OperatingSystem errorSymbolAndTextForNumber:4
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2588
    "
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2589
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2590
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2591
errorSymbolForNumber:errNr
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2592
    "return a symbol for a unix errorNumber
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2593
     (as returned by a system call)."
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2594
1153
8119975c55ce Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents: 1142
diff changeset
  2595
    ^ (self errorSymbolAndTextForNumber:errNr) at:1
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2596
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2597
    "
1666
4797ec69fc53 comment
Claus Gittinger <cg@exept.de>
parents: 1654
diff changeset
  2598
     OperatingSystem errorSymbolForNumber:4
4797ec69fc53 comment
Claus Gittinger <cg@exept.de>
parents: 1654
diff changeset
  2599
     OperatingSystem errorSymbolForNumber:2
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2600
    "
1153
8119975c55ce Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents: 1142
diff changeset
  2601
8119975c55ce Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents: 1142
diff changeset
  2602
    "Modified: 12.4.1996 / 09:16:29 / stefan"
1666
4797ec69fc53 comment
Claus Gittinger <cg@exept.de>
parents: 1654
diff changeset
  2603
    "Modified: 13.9.1996 / 16:23:35 / cg"
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2604
!
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2605
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2606
errorTextForNumber:errNr
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2607
    "return a message string from a unix errorNumber 
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2608
     (as returned by a system call). 
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2609
     The returned message is in english (as found in /usr/include/errno.h)
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2610
     and should be replaced by a resource lookup before being presented to the user."
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2611
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2612
    ^ (self errorSymbolAndTextForNumber:errNr) at:2
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2613
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2614
    "
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2615
     OperatingSystem errorTextForNumber:4
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2616
    "
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2617
!
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2618
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2619
lastErrorNumber
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2620
    "return the last errors number.
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2621
     See also: #lastErrorSymbol and #lastErrorString.
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2622
     Notice: having a single error number is a bad idea in a multithreaded
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2623
	     environment - this interface will change."
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2624
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2625
    ^ LastErrorNumber
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2626
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2627
     "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2628
      OperatingSystem lastErrorNumber
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2629
     "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2630
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2631
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2632
lastErrorString
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2633
    "return a message string describing the last error.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2634
     See also: #lastErrorNumber and #lastErrorSymbol.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2635
     Notice: having a single error number is a bad idea in a multithreaded
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2636
	     environment - this interface will change."
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2637
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2638
    ^ self errorTextForNumber:LastErrorNumber
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2639
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2640
    "
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2641
     OperatingSystem lastErrorString
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2642
    "
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2643
!
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2644
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2645
lastErrorSymbol
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2646
    "return a symbol (such as #EBADF or #EACCESS) describing the last error.
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2647
     See also: #lastErrorNumber and #lastErrorString.
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2648
     Notice: having a single error number is a bad idea in a multithreaded
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2649
	     environment - this interface will change."
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2650
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2651
    ^ self errorSymbolForNumber:LastErrorNumber
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2652
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2653
    "
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2654
     OperatingSystem lastErrorSymbol
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2655
    "
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2656
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2657
1799
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  2658
!OperatingSystem class methodsFor:'executing OS commands'!
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2659
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2660
canExecuteCommand:aCommandString
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2661
    "return true, if the OS can execute aCommand."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2662
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2663
    |cmd|
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2664
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2665
    cmd := aCommandString asCollectionOfWords first.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2666
    ^ (self pathOfCommand:cmd) notNil
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2667
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2668
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2669
     OperatingSystem canExecuteCommand:'fooBar'  
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2670
     OperatingSystem canExecuteCommand:'ls'  
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2671
     OperatingSystem canExecuteCommand:'cvs'  
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2672
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2673
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2674
    "Created: 4.11.1995 / 19:13:54 / cg"
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  2675
!
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  2676
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2677
exec:aPath withArguments:argArray
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2678
    "execute the unix command specified by the argument, aPath, with
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2679
     arguments in argArray (no arguments, if nil).
771
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2680
     If successful, this method does NOT return and smalltalk is gone.
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2681
     If not successful, false is returned. Can be used with fork or to transfer
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2682
     to another program."
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2683
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  2684
    ^ self exec:aPath withArguments:argArray fork:false
771
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2685
!
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2686
1280
b7ae6227f48b Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents: 1247
diff changeset
  2687
exec:aPath withArguments:argArray fileDescriptors:fdArray closeDescriptors:closeFdArray fork:doFork newPgrp:newPgrp
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2688
    "Internal combined fork & exec;
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2689
     If fork is false:
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2690
	 execute the unix command specified by the argument, aPath, with
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2691
	 arguments in argArray (no arguments, if nil).
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2692
	 If successful, this method does not return and smalltalk is gone.
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2693
	 If not successful, false is returned. Normal use is with forkForCommand.
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2694
     if its true:
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2695
	for a child to do the above.
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2696
	The id of the child process is returned; -1 if fork failed.
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2697
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2698
     fdArray contains the filedescriptors, to be used for the child (if fork is true).
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2699
	fdArray[1] = 15 -> use fd 15 as stdin.
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2700
	If an element of the array is set to nil, the corresponding filedescriptor
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2701
	will be closed for the child.
1062
baa5827a7a40 Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents: 1060
diff changeset
  2702
baa5827a7a40 Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents: 1060
diff changeset
  2703
     closeFdArray contains descriptors that will be closed in the subprocess.
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2704
1280
b7ae6227f48b Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents: 1247
diff changeset
  2705
     If newPgrp is true, the subprocess will be established in a new process group.
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2706
	Ths processgroup will be equal to id.
1280
b7ae6227f48b Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents: 1247
diff changeset
  2707
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2708
    Notice: this used to be two separate ST-methods; however, in order to use
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2709
	    vfork on some machines, it had to be merged into one, to avoid write
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2710
	    accesses to ST/X memory from the vforked-child. The code below only does
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2711
	    read accesses."
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2712
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2713
%{
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2714
#ifndef MSDOS_LIKE
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2715
    char **argv;
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2716
    int nargs, i, id;
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2717
    OBJ arg;
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2718
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2719
    if (__isString(aPath) && 
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2720
	((argArray == nil) || __isArray(argArray)) &&
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2721
	((fdArray == nil) || __isArray(fdArray)) &&
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2722
	((closeFdArray == nil) || __isArray(closeFdArray))
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2723
    ) {
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2724
	nargs = argArray == nil ? 0 : _arraySize(argArray);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2725
	argv = (char **) malloc(sizeof(char *) * (nargs + 1));
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2726
	if (argv) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2727
	    for (i=0; i < nargs; i++) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2728
		arg = __ArrayInstPtr(argArray)->a_element[i];
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2729
		if (__isString(arg)) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2730
		    argv[i] = (char *) __stringVal(arg);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2731
		} else {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2732
		    argv[i] = "";
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2733
		}
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2734
	    }
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2735
	    argv[i] = NULL;
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2736
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2737
	    if (doFork == true) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2738
		int nfd, nclose;
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2739
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2740
		nfd = fdArray == nil ? 0 : _arraySize(fdArray);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2741
		nclose = closeFdArray == nil ? 0 : _arraySize(closeFdArray);
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2742
#ifdef HAS_VFORK
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2743
		id = vfork();
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2744
#else
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2745
		id = fork();
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2746
#endif
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2747
		if (id == 0) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2748
		    /*
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2749
		    ** In child.
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2750
		    ** first: dup filedescriptors
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2751
		    */
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2752
		    for (i = 0; i < nfd; i++) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2753
			if (__isSmallInteger(__ArrayInstPtr(fdArray)->a_element[i]) &&
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2754
			    __intVal(__ArrayInstPtr(fdArray)->a_element[i]) != i
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2755
			) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2756
			    dup2(__intVal(__ArrayInstPtr(fdArray)->a_element[i]), i);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2757
			}
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2758
		    }
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2759
		    /*
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2760
		    ** second: close unused filedescriptors
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2761
		    */
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2762
		    for (i = 0; i < nfd; i++) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2763
			if (__ArrayInstPtr(fdArray)->a_element[i] == nil) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2764
			    close(i);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2765
			}
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2766
		    }
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2767
		    /*
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2768
		    ** third: close filedescriptors
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2769
		    */
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2770
		    for (i = 0; i < nclose; i++) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2771
			if (__isSmallInteger(__ArrayInstPtr(closeFdArray)->a_element[i])) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2772
			    close(__intVal(__ArrayInstPtr(closeFdArray)->a_element[i]));
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2773
			}
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2774
		    }
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2775
		    if (newPgrp == true) {
1280
b7ae6227f48b Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents: 1247
diff changeset
  2776
#if defined(_POSIX_JOB_CONTROL)
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2777
			(void) setpgid(0, 0);
1280
b7ae6227f48b Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents: 1247
diff changeset
  2778
#else
b7ae6227f48b Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents: 1247
diff changeset
  2779
#if defined(BSD)
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2780
			(void) setpgrp(0);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2781
#endif
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2782
#endif
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2783
		    }
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2784
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2785
		    execv(__stringVal(aPath), argv);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2786
		    /* should not be reached */
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2787
		    _exit(127);                 /* POSIX 2 compatible exit value */
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2788
		}
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2789
		/*
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2790
		** In parent: succes or failure
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2791
		*/
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2792
		free(argv);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2793
		RETURN (__MKSMALLINT(id));
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2794
	    } else {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2795
		execv(__stringVal(aPath), argv);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2796
		/* 
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2797
		 * should not be reached
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2798
		 * (well, it is, if you pass a wrong command-path)
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2799
		 */
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2800
		free(argv);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2801
		RETURN ( false );
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2802
	    }
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2803
	}
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2804
    }
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2805
#endif
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2806
%}.
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2807
    "
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2808
     path-argument not string
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2809
     or argArray not an array/nil
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2810
     or malloc failed
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2811
     or not supported by OS
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2812
    "
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2813
    ^ self primitiveFailed
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2814
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2815
    "
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2816
     |id|
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2817
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2818
     id := OperatingSystem fork.
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2819
     id == 0 ifTrue:[
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2820
	"I am the child"
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2821
	OperatingSystem exec:'/bin/ls' withArguments:#('ls' '/tmp').
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2822
	"not reached"
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2823
     ]
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2824
    "
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2825
    "
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2826
     |id|
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2828
     id := OperatingSystem fork.
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2829
     id == 0 ifTrue:[
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2830
	"I am the child"
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2831
	OperatingSystem exec:'/bin/sh' withArguments:#('sh' '-c' 'sleep 2;echo 1;sleep 2;echo 2').
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2832
	"not reached"
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2833
     ].
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2834
     id printNL.
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2835
     (Delay forSeconds:3.5) wait.
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2836
     'killing ...' printNL.
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2837
     OperatingSystem sendSignal:(OperatingSystem sigTERM) to:id.
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2838
     OperatingSystem sendSignal:(OperatingSystem sigKILL) to:id
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2839
    "
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2840
!
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2841
1076
0bfb3317718b backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents: 1062
diff changeset
  2842
exec:aPath withArguments:argArray fileDescriptors:fdArray fork:doFork
0bfb3317718b backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents: 1062
diff changeset
  2843
    "Internal combined fork & exec;
0bfb3317718b backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents: 1062
diff changeset
  2844
     If fork is false:
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2845
	 execute the unix command specified by the argument, aPath, with
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2846
	 arguments in argArray (no arguments, if nil).
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2847
	 If successful, this method does not return and smalltalk is gone.
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2848
	 If not successful, false is returned. Normal use is with forkForCommand.
1076
0bfb3317718b backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents: 1062
diff changeset
  2849
     if its true:
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2850
	for a child to do the above.
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2851
	The id of the child process is returned; -1 if fork failed.
1076
0bfb3317718b backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents: 1062
diff changeset
  2852
0bfb3317718b backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents: 1062
diff changeset
  2853
     fdArray contains the filedescriptors, to be used for the child (if fork is true).
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2854
	fdArray[1] = 15 -> use fd 15 as stdin.
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2855
	If an element of the array is set to nil, the corresponding filedescriptor
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2856
	will be closed for the child.
1076
0bfb3317718b backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents: 1062
diff changeset
  2857
0bfb3317718b backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents: 1062
diff changeset
  2858
    Notice: this used to be two separate ST-methods; however, in order to use
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2859
	    vfork on some machines, it had to be merged into one, to avoid write
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2860
	    accesses to ST/X memory from the vforked-child. The code below only does
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2861
	    read accesses."
1076
0bfb3317718b backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents: 1062
diff changeset
  2862
1280
b7ae6227f48b Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents: 1247
diff changeset
  2863
    ^ self exec:aPath withArguments:argArray fileDescriptors:fdArray closeDescriptors:nil fork:doFork newPgrp:false
b7ae6227f48b Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents: 1247
diff changeset
  2864
b7ae6227f48b Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents: 1247
diff changeset
  2865
    "Modified: 23.4.1996 / 17:05:41 / stefan"
1076
0bfb3317718b backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents: 1062
diff changeset
  2866
!
0bfb3317718b backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents: 1062
diff changeset
  2867
771
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2868
exec:aPath withArguments:argArray fork:doFork
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2869
    "Internal combined fork & exec;
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2870
     If fork is false:
813
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  2871
	 execute the unix command specified by the argument, aPath, with
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  2872
	 arguments in argArray (no arguments, if nil).
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  2873
	 If successful, this method does not return and smalltalk is gone.
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  2874
	 If not successful, false is returned. Normal use is with forkForCommand.
771
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2875
     if its true:
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  2876
	for a child to do the above.
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  2877
	The id of the child process is returned; -1 if fork failed.
771
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2878
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2879
    Notice: this used to be two separate ST-methods; however, in order to use
813
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  2880
	    vfork on some machines, it had to be merged into one, to avoid write
771
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2881
	    accesses to ST/X memory from the vforked-child. The code below only does
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2882
	    read accesses."
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2883
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2884
%{
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  2885
#ifndef MSDOS_LIKE
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2886
    char **argv;
771
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2887
    int nargs, i, id;
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2888
    OBJ arg;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2889
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2890
    if (__isString(aPath) && ((argArray == nil) || __isArray(argArray))) {
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  2891
	nargs = argArray == nil ? 0 : _arraySize(argArray);
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  2892
	argv = (char **) malloc(sizeof(char *) * (nargs + 1));
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  2893
	if (argv) {
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  2894
	    for (i=0; i < nargs; i++) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  2895
		arg = __ArrayInstPtr(argArray)->a_element[i];
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  2896
		if (__isString(arg)) {
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  2897
		    argv[i] = (char *) __stringVal(arg);
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  2898
		} else {
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  2899
		    argv[i] = "";
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  2900
		}
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  2901
	    }
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  2902
	    argv[i] = NULL;
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  2903
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  2904
	    if (doFork == true) {
771
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2905
#ifdef HAS_VFORK
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  2906
		id = vfork();
771
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2907
#else
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  2908
		id = fork();
771
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2909
#endif
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2910
		if (id == 0) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  2911
		    execv(__stringVal(aPath), argv);
771
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2912
		    /* should not be reached */
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  2913
		    _exit(127);         /* POSIX-2 compatible exit value */
771
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2914
		}
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2915
		free(argv);
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2916
		RETURN (__MKSMALLINT(id));
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2917
	    } else {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  2918
		execv(__stringVal(aPath), argv);
813
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  2919
		/* 
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  2920
		 * should not be reached
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  2921
		 * (well, it is, if you pass a wrong command-path)
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  2922
		 */
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  2923
		free(argv);
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  2924
		RETURN ( false );
771
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2925
	    }
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2926
	}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2927
    }
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  2928
#endif
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2929
%}.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2930
    "
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  2931
     path-argument not string
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  2932
     or argArray not an array/nil
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  2933
     or malloc failed
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  2934
     or not supported by OS
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2935
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2936
    ^ self primitiveFailed
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2937
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2938
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2939
     |id|
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2940
771
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2941
     id := OperatingSystem fork.
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2942
     id == 0 ifTrue:[
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  2943
	"I am the child"
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  2944
	OperatingSystem exec:'/bin/ls' withArguments:#('ls' '/tmp').
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  2945
	"not reached"
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2946
     ]
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2947
    "
670
4d6d0c031711 startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents: 640
diff changeset
  2948
    "
4d6d0c031711 startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents: 640
diff changeset
  2949
     |id|
4d6d0c031711 startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents: 640
diff changeset
  2950
771
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2951
     id := OperatingSystem fork.
670
4d6d0c031711 startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents: 640
diff changeset
  2952
     id == 0 ifTrue:[
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  2953
	"I am the child"
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  2954
	OperatingSystem exec:'/bin/sh' withArguments:#('sh' '-c' 'sleep 2;echo 1;sleep 2;echo 2').
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  2955
	"not reached"
670
4d6d0c031711 startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents: 640
diff changeset
  2956
     ].
4d6d0c031711 startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents: 640
diff changeset
  2957
     id printNL.
4d6d0c031711 startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents: 640
diff changeset
  2958
     (Delay forSeconds:3.5) wait.
4d6d0c031711 startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents: 640
diff changeset
  2959
     'killing ...' printNL.
4d6d0c031711 startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents: 640
diff changeset
  2960
     OperatingSystem sendSignal:(OperatingSystem sigTERM) to:id.
4d6d0c031711 startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents: 640
diff changeset
  2961
     OperatingSystem sendSignal:(OperatingSystem sigKILL) to:id
4d6d0c031711 startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents: 640
diff changeset
  2962
    "
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2963
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2964
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2965
executeCommand:aCommandString
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2966
    "execute the unix command specified by the argument, aCommandString.
676
4aa4417c103c commentary
Claus Gittinger <cg@exept.de>
parents: 675
diff changeset
  2967
     The commandString is passed to a shell for execution - see the description of
4aa4417c103c commentary
Claus Gittinger <cg@exept.de>
parents: 675
diff changeset
  2968
     'sh -c' in your UNIX manual.
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2969
     Return true if successful, false otherwise."
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2970
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2971
     ^ self executeCommand:aCommandString onError:[:status| false]
2080
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2972
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2973
"/Old code:
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2974
"/
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2975
"/%{ 
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2976
"/    int status;
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2977
"/
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2978
"/    if (__isString(aCommandString)) {
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2979
"/        /*
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2980
"/         * ST/X provides a modified (fixed) implementation of the
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2981
"/         * system() libc-function, which is interruptable ...
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2982
"/         */
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2983
"/# ifdef WANT_SYSTEM
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2984
"/        status = mySystem((char *) __stringVal(aCommandString));
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2985
"/# else
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2986
"/        status = system((char *) __stringVal(aCommandString));
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2987
"/# endif
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2988
"/        OperatingSystem_LastExecStatus = __MKSMALLINT(status);
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2989
"/        if (status == 0) {
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2990
"/            RETURN ( true );
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2991
"/        }
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2992
"/        OperatingSystem_LastErrorNumber = __MKSMALLINT(errno);
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2993
"/        RETURN ( false );
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2994
"/    }
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2995
"/%}.
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2996
"/    "/
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2997
"/    "/ invalid argument (non-string)
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2998
"/    "/
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2999
"/    ^ self primitiveFailed
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3000
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3001
    "
805
850571f0255f WANT_SYSTEM for unixware.
Stefan Vogel <sv@exept.de>
parents: 803
diff changeset
  3002
     OperatingSystem executeCommand:'sleep 30'. 
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3003
     OperatingSystem executeCommand:'pwd'. 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3004
     OperatingSystem executeCommand:'ls -l'. 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3005
     OperatingSystem executeCommand:'invalidCommand'. 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3006
     OperatingSystem executeCommand:'rm /tmp/foofoofoofoo'. 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3007
    "
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3008
2080
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  3009
    "Modified: 7.1.1997 / 19:29:55 / stefan"
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3010
!
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3011
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3012
executeCommand:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream errorTo:anExternalErrStream onError:aBlock
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3013
    "execute the unix command specified by the argument, aCommandString.
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3014
     The commandString is passed to a shell for execution - see the description of
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3015
     'sh -c' in your UNIX manual.
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3016
     Return true if successful.
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3017
     If not successfull, aBlock is called with a Dictionary containing the exit status
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3018
     as argument."
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3019
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3020
    |pid exitStatus sema|
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3021
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3022
    sema := Semaphore new.
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3023
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3024
    [
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3025
	pid := self 
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3026
		startProcess:aCommandString
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3027
		inputFrom:anExternalInStream 
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3028
		outputTo:anExternalOutStream 
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3029
		errorTo:anExternalErrStream.
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3030
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3031
	pid > 0 ifTrue:[
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3032
	    Processor monitorPid:pid action:[:status |
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3033
		status stillAlive ifFalse:[
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3034
		    exitStatus := status.
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3035
		    sema signal
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3036
		].
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3037
	    ].
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3038
	    sema wait.
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3039
	] ifFalse:[
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3040
	    exitStatus := OSProcessStatus processCreationFailure.
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3041
	].
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3042
    ] valueUninterruptably.
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3043
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3044
    exitStatus success ifFalse:[
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3045
	^ aBlock value:exitStatus
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3046
    ].
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3047
    ^ true.
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3048
!
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3049
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3050
executeCommand:aCommandString onError:aBlock
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3051
    "execute the unix command specified by the argument, aCommandString.
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3052
     The commandString is passed to a shell for execution - see the description of
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3053
     'sh -c' in your UNIX manual.
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3054
     Return true if successful.
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3055
     If not successfull, aBlock is called with a Dictionary containing the exit status
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3056
     as argument."
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3057
1034
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3058
    |pid exitStatus sema|
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3059
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3060
    sema := Semaphore new.
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3061
1034
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3062
    [
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3063
	pid := self startProcess:aCommandString.
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3064
	pid > 0 ifTrue:[
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3065
	    Processor monitorPid:pid action:[:status |
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3066
		status stillAlive ifFalse:[
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3067
		    exitStatus := status.
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3068
		    sema signal
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3069
		].
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3070
	    ].
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3071
	    sema wait.
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3072
	] ifFalse:[
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3073
	    exitStatus := OSProcessStatus processCreationFailure.
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3074
	].
1034
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3075
    ] valueUninterruptably.
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3076
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3077
    exitStatus success ifFalse:[
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3078
	^ aBlock value:exitStatus
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3079
    ].
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3080
    ^ true.
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3081
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3082
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3083
    "
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3084
     OperatingSystem executeCommand:'sleep 30' onError:[]. 
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3085
     OperatingSystem executeCommand:'pwd' onError:[:status|status inspect]. 
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3086
     OperatingSystem executeCommand:'ls -l' onError:[]. 
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3087
     OperatingSystem executeCommand:'invalidCommand' onError:[:status| status inspect]. 
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3088
     OperatingSystem executeCommand:'rm /tmp/foofoofoofoo'onError:[:status | status inspect]. 
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3089
    "
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3090
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3091
    "Created: 22.12.1995 / 14:49:59 / stefan"
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3092
    "Modified: 28.12.1995 / 15:25:48 / stefan"
1034
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3093
    "Modified: 28.2.1996 / 21:41:23 / cg"
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3094
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3095
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3096
fork
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3097
    "fork a new (HEAVY-weight) unix process.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3098
     Dont confuse this with Block>>fork, which creates 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3099
     lightweight smalltalk processes. This method will return
676
4aa4417c103c commentary
Claus Gittinger <cg@exept.de>
parents: 675
diff changeset
  3100
     0 to the child process, and a non-zero number (which is the childs
4aa4417c103c commentary
Claus Gittinger <cg@exept.de>
parents: 675
diff changeset
  3101
     unix-process-id) to the parent (original) process.
764
eadba1b6a721 vfork interface (for poor BSD ultrix) - without it, it takes 20 seconds
Claus Gittinger <cg@exept.de>
parents: 763
diff changeset
  3102
676
4aa4417c103c commentary
Claus Gittinger <cg@exept.de>
parents: 675
diff changeset
  3103
     In normal situations, you dont need to use this low level entry; see
771
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  3104
     #startProcess: and #executCommand: for higher level interfaces."
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  3105
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  3106
%{  /* NOCONTEXT */
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  3107
#ifndef MSDOS_LIKE
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3108
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3109
    int pid;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3110
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3111
    pid = fork();
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  3112
    RETURN ( __MKSMALLINT(pid) );
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  3113
#endif
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  3114
%}.
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  3115
    "/
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  3116
    "/ not supported by OS
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  3117
    "/
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  3118
    ^ self primitiveFailed
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  3119
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3120
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3121
     |id|
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3122
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3123
     id := OperatingSystem fork.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3124
     id == 0 ifTrue:[
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3125
	OperatingSystem exit
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3126
     ]
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3127
    "
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  3128
!
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  3129
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3130
getStatusOfProcess:aProcessId
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3131
    "wait for a process to terminate and fetch its exit status.
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3132
     This is required to avoid zombie processes."
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3133
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3134
%{
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3135
#ifndef MSDOS_LIKE
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3136
    int status;
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3137
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3138
    if (__isSmallInteger(aProcessId)) {
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3139
	pid_t pid = (pid_t)(__intVal(aProcessId));
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3140
	{
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3141
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3142
# ifdef  NO_WAITPID
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3143
	    pid_t child;
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3144
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3145
	    do {
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3146
		__BEGIN_INTERRUPTABLE__
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3147
		child = __wait (&status);
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3148
		__END_INTERRUPTABLE__
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3149
		if (child < 0 && errno != EINTR) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  3150
		    fprintf(stderr, "OS: child-wait errno=%d\n", errno);
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3151
		    status = -1;
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3152
		    break;
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3153
		}
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3154
	    } while (child != pid);
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3155
# else
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3156
	    pid_t child;
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3157
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3158
	    /* claus: the original did not care for EINTR here ... */
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3159
	    do {
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3160
		__BEGIN_INTERRUPTABLE__
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3161
		child = __waitpid (pid, &status, 0);
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3162
		__END_INTERRUPTABLE__
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3163
	    } while ((child != pid) && (errno == EINTR));
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3164
	    if (child != pid) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  3165
		fprintf(stderr, "OS: child-waitpid errno=%d\n", errno);
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3166
		status = -1;
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3167
	    }
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3168
# endif /* NO_WAITPID */
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3169
	}
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3170
	RETURN ( __MKSMALLINT(status));
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3171
    }
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3172
#endif
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3173
%}.
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3174
    self primitiveFailed
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3175
1034
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3176
!
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3177
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3178
pathOfCommand:aCommand
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3179
    "find where aCommand's executable file is"
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3180
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3181
    |path f|
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3182
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3183
    path := self getEnvironment:'PATH'.
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3184
    path notNil ifTrue:[
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3185
	(path asCollectionOfSubstringsSeparatedBy:$:) do:[:path |
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3186
	    (f := (path asFilename construct:aCommand)) isExecutable ifTrue:[
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3187
		^  f pathName
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3188
	    ]
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3189
	].
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3190
    ].
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3191
    ^ nil
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3192
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3193
    "
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3194
     OperatingSystem pathOfCommand:'fooBar'  
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3195
     OperatingSystem pathOfCommand:'ls'  
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3196
     OperatingSystem pathOfCommand:'cvs'  
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3197
    "
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3198
!
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3199
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3200
startProcess:aCommandString
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3201
    "start executing the unix command as specified by the argument, aCommandString
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3202
     as a separate process; do not wait for the command to finish.
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3203
     The commandString is passed to a shell for execution - see the description of
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3204
     'sh -c' in your UNIX manual.
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3205
     Return the processId if successful, nil otherwise.
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3206
     Use #waitForProcess: for synchronization and exec status return,
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3207
     or #killProcess: to stop it."
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3208
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3209
    ^ self 
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3210
	exec:'/bin/sh' 
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3211
	withArguments:(Array with:'sh' with:'-c' with:aCommandString)
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3212
	fork:true.
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3213
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3214
    "
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3215
     |pid|
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3216
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3217
     pid := OperatingSystem startProcess:'sleep 2; echo 1; sleep 2; echo 2'.
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3218
     (Delay forSeconds:3) wait.
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3219
     OperatingSystem killProcess:pid.
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3220
    "
1045
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3221
!
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3222
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3223
startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream errorTo:anExternalErrStream
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3224
    "start executing the unix command as specified by the argument, aCommandString
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3225
     as a separate process; do not wait for the command to finish.
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3226
     The commandString is passed to a shell for execution - see the description of
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3227
     'sh -c' in your UNIX manual.
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3228
     The command gets stdIn, stdOut and stdErr assigned from the arguments;
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3229
     each may be nil.
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3230
     Return the processId if successful, nil otherwise.
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3231
     Use #monitorPid:action: for synchronization and exec status return,
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3232
     or #killProcess: to stop it."
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3233
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3234
    |in out err|
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3235
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3236
    anExternalInStream notNil ifTrue:[
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3237
	in := anExternalInStream fileDescriptor.
1046
7b50e6c3147f nil input -> /dev/null
ca
parents: 1045
diff changeset
  3238
    ] ifFalse:[
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3239
	in := '/dev/null' asFilename readStream fileDescriptor
1045
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3240
    ].
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3241
    anExternalOutStream notNil ifTrue:[
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3242
	out := anExternalOutStream fileDescriptor.
1045
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3243
    ].
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3244
    anExternalErrStream notNil ifTrue:[
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3245
	err := anExternalErrStream fileDescriptor.
1045
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3246
    ].
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3247
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3248
    ^ self 
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3249
	exec:'/bin/sh' 
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3250
	withArguments:(Array with:'sh' with:'-c' with:aCommandString)
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3251
	fileDescriptors:(Array with:in with:out with:err)
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3252
	fork:true.
1045
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3253
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3254
    "blocking at current prio (i.e. only higher prio threads execute):
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3255
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3256
     OperatingSystem executeCommand:'ls -l > out'.
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3257
    "
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3258
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3259
    "non-blocking (lower prio threads continue):
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3260
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3261
     |in out err pid sema|
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3262
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3263
     in := 'out' asFilename readStream.
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3264
     out := 'out2' asFilename writeStream.
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3265
     err := 'err' asFilename writeStream.
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3266
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3267
     sema := Semaphore new.
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3268
     pid := OperatingSystem startProcess:'sleep 10; grep drw' inputFrom:in outputTo:out errorTo:err.
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3269
     pid notNil ifTrue:[
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3270
	 Processor monitorPid:pid action:[:OSstatus | sema signal ].
1045
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3271
     ].
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3272
     in close.
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3273
     out close.
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3274
     err close.
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3275
     sema wait.
1422
9a0b792f2953 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  3276
     Transcript showCR:'finished'
1045
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3277
    "
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3278
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3279
    "Created: 29.2.1996 / 12:31:29 / cg"
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3280
    "Modified: 29.2.1996 / 12:49:14 / cg"
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3281
! !
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3282
1799
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  3283
!OperatingSystem class methodsFor:'file access'!
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3284
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3285
closeFd:anInteger
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3286
    "low level close of a filedescriptor"
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3287
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3288
%{
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3289
#if !defined(transputer) && !defined(MSDOS_LIKE)
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3290
     if (__isSmallInteger(anInteger)) {
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3291
	close(__intVal(anInteger));
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3292
	RETURN(self);
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3293
     }
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3294
#endif
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3295
%}.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3296
     ^ self primitiveFailed.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3297
!
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3298
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3299
createDirectory:newPathName
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3300
    "create a new directory with name 'newPathName'.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3301
     Return true if successful, false if failed.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3302
     This is a low-level entry - use Filename protocol for compatibility."
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3303
1497
92f5370f3942 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
  3304
    "/ if it already exists this is ok
92f5370f3942 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
  3305
92f5370f3942 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
  3306
    (self isDirectory:newPathName) ifTrue:[^ true].
92f5370f3942 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
  3307
92f5370f3942 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
  3308
    "/ since createDirectory is not used too often,
92f5370f3942 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
  3309
    "/  you'll forgive me using mkdir ...
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3310
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3311
    ^ self executeCommand:('mkdir 2>/dev/null ', newPathName)
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3312
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3313
    "
1497
92f5370f3942 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
  3314
     OperatingSystem createDirectory:'foo'  
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3315
    "
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3316
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3317
    "Modified: 20.12.1995 / 11:24:13 / stefan"
1497
92f5370f3942 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
  3318
    "Modified: 29.6.1996 / 14:06:54 / cg"
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3319
!
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3320
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3321
linkFile:oldPath to:newPath
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3322
    "link the file 'oldPath' to 'newPath'. The link will be a hard link.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3323
     Return true if successful, false if not."
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3324
1104
219a06128193 removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents: 1084
diff changeset
  3325
%{
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3326
#ifndef MSDOS_LIKE
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3327
    int ret;
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3328
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3329
    if (__isString(oldPath) && __isString(newPath)) {
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3330
	__BEGIN_INTERRUPTABLE__
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3331
	do {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3332
	    ret = link((char *) __stringVal(oldPath), (char *) __stringVal(newPath));
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3333
	} while (ret < 0 && errno == EINTR);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3334
	__END_INTERRUPTABLE__
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3335
	if (ret < 0) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3336
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3337
	    RETURN ( false );
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3338
	}
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3339
	RETURN (true);
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3340
    }
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3341
#endif
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3342
%}.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3343
    ^ self primitiveFailed
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3344
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3345
    "
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3346
     OperatingSystem linkFile:'foo' to:'bar'
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3347
    "
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3348
!
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3349
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3350
makePipe
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3351
    "make a pipe, return array with two filedescriptors on success,
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3352
     nil on failure.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3353
     This is a lowLevel entry, not for public use.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3354
     See ExternalStream>>makePipe for a more user-friendly, public interface."
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3355
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3356
    |fd1 fd2|    
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3357
                
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3358
%{       
1597
f35cd92a7648 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
  3359
#ifdef UNIX_LIKE
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3360
     int fds[2];
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3361
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3362
     if (pipe(fds) < 0) {
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3363
	@global(LastErrorNumber) = __MKSMALLINT(errno);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3364
	RETURN ( nil );
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3365
     }
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3366
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3367
     fd1 = __MKSMALLINT(fds[0]);
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3368
     fd2 = __MKSMALLINT(fds[1]);
1597
f35cd92a7648 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
  3369
#endif
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3370
%}.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3371
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3372
     ^ Array with:fd1 with:fd2.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3373
!
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3374
1132
b09ce8542506 checkin from browser
ca
parents: 1119
diff changeset
  3375
recursiveCopyDirectory:sourcePathName to:destination
b09ce8542506 checkin from browser
ca
parents: 1119
diff changeset
  3376
    "copy the directory named 'sourcePathName' and all contained files/directories to 'destination'.
b09ce8542506 checkin from browser
ca
parents: 1119
diff changeset
  3377
     Return true if successful."
b09ce8542506 checkin from browser
ca
parents: 1119
diff changeset
  3378
b09ce8542506 checkin from browser
ca
parents: 1119
diff changeset
  3379
    ^ self executeCommand:('cp -rf ' , sourcePathName, ' ', destination)
b09ce8542506 checkin from browser
ca
parents: 1119
diff changeset
  3380
b09ce8542506 checkin from browser
ca
parents: 1119
diff changeset
  3381
    "Modified: 7.3.1996 / 15:26:30 / cg"
b09ce8542506 checkin from browser
ca
parents: 1119
diff changeset
  3382
!
b09ce8542506 checkin from browser
ca
parents: 1119
diff changeset
  3383
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3384
recursiveCreateDirectory:dirName
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3385
    "create a directory - with all parent dirs if needed.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3386
     Return true if successful, false otherwise. If false
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3387
     is returned, a partial created tree may be left,
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3388
     which is not cleaned-up here."
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3389
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3390
    self createDirectory:dirName.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3391
    (self isDirectory:dirName) ifFalse:[
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3392
	(self recursiveCreateDirectory:(self directoryNameOf:dirName)) ifFalse:[^ false].
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3393
	^ self createDirectory:dirName
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3394
    ].
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3395
    ^ true
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3396
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3397
    "
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3398
     OperatingSystem recursiveCreateDirectory:'foo/bar/baz'
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3399
     OperatingSystem recursiveRemoveDirectory:'foo'
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3400
    "
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3401
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3402
    "Modified: 7.3.1996 / 15:26:22 / cg"
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3403
!
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3404
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3405
recursiveRemoveDirectory:fullPathName
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3406
    "remove the directory named 'fullPathName' and all contained files/directories.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3407
     Return true if successful."
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3408
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3409
    ^ self executeCommand:('rm -rf ' , fullPathName)
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3410
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3411
    "
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3412
     OperatingSystem recursiveCreateDirectory:'foo/bar/baz'
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3413
     OperatingSystem recursiveRemoveDirectory:'foo'
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3414
    "
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3415
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3416
    "Modified: 7.3.1996 / 15:26:30 / cg"
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3417
!
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3418
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3419
removeDirectory:fullPathName
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3420
    "remove the directory named 'fullPathName'.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3421
     Return true if successful, false if directory is not empty or no permission.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3422
     This is a lowLevel entry - use Filename protocol for compatibility."
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3423
1104
219a06128193 removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents: 1084
diff changeset
  3424
%{
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3425
    int ret;
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3426
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3427
    if (__isString(fullPathName)) {
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3428
	__BEGIN_INTERRUPTABLE__
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3429
	do {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3430
	    ret = rmdir((char *) __stringVal(fullPathName));
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3431
	} while (ret < 0 && errno == EINTR);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3432
	__END_INTERRUPTABLE__
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3433
	if (ret < 0) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3434
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3435
	    RETURN ( false );
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3436
	}
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3437
	RETURN (true);
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3438
    }
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3439
%}.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3440
    ^ self primitiveFailed
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3441
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3442
    "
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3443
     OperatingSystem createDirectory:'foo'
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3444
     OperatingSystem removeDirectory:'foo'
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3445
    "
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3446
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3447
!
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3448
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3449
removeFile:fullPathName
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3450
    "remove the file named 'fullPathName'; return true if successful.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3451
     This is a lowLevel entry - use Filename protocol for compatibility."
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3452
1104
219a06128193 removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents: 1084
diff changeset
  3453
%{
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3454
    int ret;
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3455
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3456
    if (__isString(fullPathName)) {
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3457
	__BEGIN_INTERRUPTABLE__
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3458
	do {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3459
	    ret = unlink((char *) __stringVal(fullPathName));
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3460
	} while (ret < 0 && errno == EINTR);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3461
	__END_INTERRUPTABLE__
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3462
	if (ret < 0) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3463
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3464
	    RETURN ( false );
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3465
	}
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3466
	RETURN (true);
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3467
    }
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3468
%}.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3469
    ^ self primitiveFailed
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3470
!
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3471
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3472
renameFile:oldPath to:newPath
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3473
    "rename the file 'oldPath' to 'newPath'. 
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3474
     Return true if successful, false if not"
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3475
1104
219a06128193 removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents: 1084
diff changeset
  3476
%{
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3477
    int ret, eno;
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3478
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3479
    if (__isString(oldPath) && __isString(newPath)) {
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3480
#if defined(HAS_RENAME)
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3481
	__BEGIN_INTERRUPTABLE__
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3482
	do {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3483
	    ret = rename((char *) __stringVal(oldPath), (char *) __stringVal(newPath));
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3484
	} while (ret < 0 && errno == EINTR);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3485
	__END_INTERRUPTABLE__
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3486
#else
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3487
# ifndef MSDOS_LIKE
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3488
	ret = link((char *) __stringVal(oldPath), (char *) __stringVal(newPath));
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3489
	if (ret >= 0) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3490
	    ret = unlink((char *) __stringVal(oldPath));
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3491
	    if (ret < 0) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3492
		eno = errno;
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3493
		unlink((char *) __stringVal(newPath));
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3494
		errno = eno;
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3495
	    }
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3496
	}
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3497
# endif
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3498
#endif
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3499
	if (ret < 0) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3500
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3501
	    RETURN ( false );
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3502
	}
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3503
	RETURN (true);
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3504
    }
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3505
%}.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3506
    ^ self primitiveFailed
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3507
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3508
    "
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3509
     OperatingSystem renameFile:'foo' to:'bar'
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3510
    "
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3511
!
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3512
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3513
truncateFile:aPathName to:newSize
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3514
    "change a files size return true on success, false on failure.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3515
     This may not be supported on all architectures.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3516
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3517
     This is a low-level entry - use Filename protocol."
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3518
1104
219a06128193 removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents: 1084
diff changeset
  3519
%{
1623
95009f9bfc18 use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
  3520
#ifdef HAS_TRUNCATE
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3521
    int ret;
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3522
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3523
    if (__isString(aPathName)
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3524
     && __isSmallInteger(newSize)) {
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3525
	__BEGIN_INTERRUPTABLE__
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3526
	do {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3527
	    ret = truncate((char *) __stringVal(aPathName), __intVal(newSize));
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3528
	} while (ret < 0 && errno == EINTR);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3529
	__END_INTERRUPTABLE__
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3530
	if (ret < 0) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3531
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3532
	    RETURN ( false );
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3533
	}
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3534
	RETURN (true);
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3535
    }
1623
95009f9bfc18 use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
  3536
#else
95009f9bfc18 use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
  3537
# ifdef HAS_FTRUNCATE
95009f9bfc18 use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
  3538
    int ret;
95009f9bfc18 use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
  3539
    int fd;
95009f9bfc18 use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
  3540
95009f9bfc18 use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
  3541
    if (__isString(aPathName)
95009f9bfc18 use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
  3542
     && __isSmallInteger(newSize)) {
95009f9bfc18 use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
  3543
	do {
95009f9bfc18 use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
  3544
	    fd = open((char *) __stringVal(aPathName), 2);
95009f9bfc18 use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
  3545
	} while (fd < 0 && errno == EINTR);
95009f9bfc18 use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
  3546
	if (fd < 0) {
95009f9bfc18 use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
  3547
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
95009f9bfc18 use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
  3548
	    RETURN ( false );
95009f9bfc18 use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
  3549
	}
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3550
        
1623
95009f9bfc18 use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
  3551
	ret = ftruncate(fd, __intVal(newSize));
95009f9bfc18 use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
  3552
	close(fd);
95009f9bfc18 use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
  3553
	if (ret < 0) {
95009f9bfc18 use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
  3554
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
95009f9bfc18 use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
  3555
	    RETURN ( false );
95009f9bfc18 use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
  3556
	} 
95009f9bfc18 use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
  3557
	RETURN (true);
95009f9bfc18 use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
  3558
    }
95009f9bfc18 use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
  3559
# endif /* using FTRUNCATE */
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3560
#endif
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3561
%}.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3562
    ^ self primitiveFailed
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3563
! !
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3564
1799
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  3565
!OperatingSystem class methodsFor:'file access rights'!
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3566
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3567
accessMaskFor:aSymbol
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3568
    "return the access bits mask for numbers as returned by 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3569
     OperatingSystem>>accessModeOf:
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3570
     and expected by OperatingSystem>>changeAccessModeOf:to:.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3571
     Since these numbers are OS dependent, always use the mask
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3572
     (never hardcode 8rxxx into your code)."
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  3573
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  3574
%{  /* NOCONTEXT */
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3575
#   ifndef S_IRUSR
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3576
    /* posix systems should define these ... */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3577
#    define S_IRUSR 0400
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3578
#    define S_IWUSR 0200
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3579
#    define S_IXUSR 0100
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3580
#    define S_IRGRP 0040
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3581
#    define S_IWGRP 0020
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3582
#    define S_IXGRP 0010
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3583
#    define S_IROTH 0004
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3584
#    define S_IWOTH 0002
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3585
#    define S_IXOTH 0001
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3586
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3587
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3588
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3589
    if (aSymbol == @symbol(readUser)) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  3590
	RETURN ( __MKSMALLINT(S_IRUSR) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3591
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3592
    if (aSymbol == @symbol(writeUser)) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  3593
	RETURN ( __MKSMALLINT(S_IWUSR) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3594
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3595
    if (aSymbol == @symbol(executeUser)) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  3596
	RETURN ( __MKSMALLINT(S_IXUSR) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3597
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3598
    if (aSymbol == @symbol(readGroup)) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  3599
	RETURN ( __MKSMALLINT(S_IRGRP) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3600
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3601
    if (aSymbol == @symbol(writeGroup)) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  3602
	RETURN ( __MKSMALLINT(S_IWGRP) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3603
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3604
    if (aSymbol == @symbol(executeGroup)) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  3605
	RETURN ( __MKSMALLINT(S_IXGRP) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3606
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3607
    if (aSymbol == @symbol(readOthers)) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  3608
	RETURN ( __MKSMALLINT(S_IROTH) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3609
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3610
    if (aSymbol == @symbol(writeOthers)) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  3611
	RETURN ( __MKSMALLINT(S_IWOTH) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3612
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3613
    if (aSymbol == @symbol(executeOthers)) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  3614
	RETURN ( __MKSMALLINT(S_IXOTH) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3615
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3616
%}.
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  3617
    ^ self primitiveFailed
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3618
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3619
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3620
     OperatingSystem accessMaskFor:#readUser
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3621
    "
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  3622
!
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  3623
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3624
accessModeOf:aPathName
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3625
    "return a number representing access rights rwxrwxrwx for owner,
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3626
     group and others. Return nil if such a file does not exist.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3627
     Notice that the returned number is OS dependent - use the 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3628
     modeMasks as returned by OperatingSystem>>accessMaskFor:"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3629
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3630
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3631
     this could have been implemented as:
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3632
	(self infoOf:aPathName) at:#mode
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3633
     but for huge directory searches the code below is faster
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3634
    "
345
claus
parents: 329
diff changeset
  3635
1104
219a06128193 removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents: 1084
diff changeset
  3636
%{
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3637
    struct stat buf;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3638
    int ret;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3639
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3640
    if (__isString(aPathName)) {
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3641
	__BEGIN_INTERRUPTABLE__
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3642
	do {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3643
	    ret = stat((char *) __stringVal(aPathName), &buf);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3644
	} while ((ret < 0) && (errno == EINTR));
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3645
	__END_INTERRUPTABLE__
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3646
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3647
	if (ret < 0) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3648
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3649
	    RETURN ( nil );
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3650
	}
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3651
	RETURN ( __MKSMALLINT(buf.st_mode & 0777) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3652
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3653
%}.
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  3654
   ^ self primitiveFailed
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3655
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3656
   "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3657
    (OperatingSystem accessModeOf:'/') printStringRadix:8
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3658
   "
345
claus
parents: 329
diff changeset
  3659
!
claus
parents: 329
diff changeset
  3660
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3661
changeAccessModeOf:aPathName to:modeBits
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3662
    "change the access rights of aPathName to the OS dependent modeBits.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3663
     You should construct this mask using accessMaskFor, to be OS
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3664
     independent. Return true if changed, 
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3665
     false if such a file does not exist or change was not allowd."
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3666
1104
219a06128193 removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents: 1084
diff changeset
  3667
%{
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3668
    int ret;
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3669
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3670
    if (__isString(aPathName) && __isSmallInteger(modeBits)) {
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3671
	__BEGIN_INTERRUPTABLE__
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3672
	do {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3673
	    ret = chmod((char *)__stringVal(aPathName), __intVal(modeBits));
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3674
	} while (ret < 0 && errno == EINTR);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3675
	__END_INTERRUPTABLE__
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3676
	if (ret < 0) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3677
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3678
	    RETURN ( false );
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3679
	}
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3680
	RETURN ( true );
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3681
    }
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3682
%}.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3683
    ^ self primitiveFailed
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3684
! !
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3685
1799
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  3686
!OperatingSystem class methodsFor:'file locking'!
1615
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3687
1617
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3688
lockFD:aFileDescriptor shared:isSharedReadLock blocking:blockIfLocked
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3689
   "set a lock on the file represented by aFileDescriptor.
1615
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3690
    (such as returned by ExternalStream>>fileDescriptor).
1617
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3691
    On some systems, only advisory locks are available -
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3692
    these depends on other accessors to also perform the locking operation.
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3693
    If they do not, they may still access the file 
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3694
    (on some systems, locks are mandatory, on others, they are advisory). 
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3695
    The isSharedReadLock argument (if true) specifies if multiple readers
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3696
    are to be allowed - if false, they are not.
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3697
    On some systems, all locks are non-exclusive locks.
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3698
1615
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3699
    Returns true, if the lock was aquired, false otherwise.
1617
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3700
1616
fa734ea238f8 type & include file.h on all systems
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
  3701
    Notice, that not all OS's support these locks; 
fa734ea238f8 type & include file.h on all systems
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
  3702
    on some, this may simply be a no-op.
1615
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3703
    Also notice, that some systems block the process, to wait for the lock.
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3704
    This can (again: on some systems) be avoided by passing a false blockIfLocked
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3705
    argument."
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3706
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3707
%{
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3708
    if (__isSmallInteger(aFileDescriptor)) {
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3709
	int fd = __intVal(aFileDescriptor);
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3710
	int lockArg;
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3711
1617
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3712
	/*
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3713
	 * claus: sigh - each one has a different interface ... 
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3714
	 */
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3715
#if defined(F_SETLK)
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3716
	{
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3717
	    /* 
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3718
	     * new fcntl(SETLK) interface;
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3719
	     * available on SYSV4 and Linux
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3720
	     */
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3721
	    struct flock flock;
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3722
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3723
	    if (isSharedReadLock == true) {
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3724
		flock.l_type = F_RDLCK;
1617
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3725
	    } else {
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3726
		flock.l_type = F_WRLCK;
1617
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3727
	    }
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3728
	    flock.l_whence = 0;
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3729
	    flock.l_start = 0;
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3730
	    flock.l_len = 0;
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3731
	    lockArg = F_SETLK;
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3732
# if defined(F_SETLKW)
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3733
	    if (blockIfLocked == true) {
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3734
		lockArg = F_SETLKW;
1617
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3735
	    }
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3736
# endif
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3737
	    if (fcntl(fd, lockArg, &flock) != -1) {
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3738
		RETURN (true);
1617
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3739
	    }
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3740
	}
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3741
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3742
#else /* no F_SETLK available */
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3743
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3744
# if defined(LOCK_EX) && defined(LOCK_UN)
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3745
	/* 
1617
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3746
	 * BSD 4.3 advisory locks
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3747
	 */
1615
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3748
	lockArg = LOCK_EX;
1617
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3749
#  if defined(LOCK_SH)
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3750
	if (isSharedReadLock == true) {
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3751
	    lockArg = LOCK_SH
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3752
	}
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3753
#  endif
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3754
#  if defined(LOCK_NB)
1615
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3755
	if (blockIfLocked == false) {
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3756
	    lockArg |= LOCK_NB;
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3757
	}
1617
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3758
#  endif
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3759
	if (flock(fd, lockArg) != -1) {
1615
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3760
	    RETURN (true);
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3761
	}
1617
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3762
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3763
# else /* no flock available */
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3764
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3765
#  if defined(F_LOCK) && defined(F_UNLOCK)
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3766
	/* 
1617
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3767
	 * SYSV3 advisory locks
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3768
	 */
1615
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3769
	if (lockf(fd, F_LOCK, 0) != -1) {
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3770
	    RETURN (true);
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3771
	}
1617
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3772
#  endif
1615
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3773
# endif
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3774
#endif
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3775
    }
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3776
%}.
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3777
    ^ false
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3778
!
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3779
1616
fa734ea238f8 type & include file.h on all systems
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
  3780
supportsFileLocks
1617
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3781
    "return true, if the OS supports file locking"
1615
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3782
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3783
%{ /* NOCONTEXT */
1617
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3784
#if defined(F_SETLK)
1615
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3785
    RETURN (true);
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3786
#else
1617
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3787
# if defined(LOCK_EX) && defined(LOCK_UN)
1615
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3788
    RETURN (true);
1617
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3789
# else
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3790
#  if defined(F_LOCK) && defined(F_UNLOCK)
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3791
    RETURN (true);
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3792
#  endif
1615
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3793
# endif
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3794
#endif
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3795
%}.
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3796
    ^ false
1616
fa734ea238f8 type & include file.h on all systems
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
  3797
fa734ea238f8 type & include file.h on all systems
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
  3798
    "
fa734ea238f8 type & include file.h on all systems
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
  3799
     OperatingSystem supportsFileLocks
fa734ea238f8 type & include file.h on all systems
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
  3800
    "
1617
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3801
!
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3802
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3803
supportsNonBlockingFileLocks
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3804
    "return true, if the OS supports nonBlocking file locking
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3805
     (i.e. with immediate return instead of waiting for the lock)"
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3806
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3807
%{ /* NOCONTEXT */
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3808
#if defined(F_SETLK) && defined(F_SETLKW)
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3809
    RETURN (true);
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3810
#else
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3811
# if defined(LOCK_EX) && defined(LOCK_UN) && defined(LOCK_NB)
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3812
    RETURN (true);
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3813
# endif
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3814
#endif
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3815
%}.
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3816
    ^ false
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3817
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3818
    "
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3819
     OperatingSystem supportsNonBlockingFileLocks
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3820
    "
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3821
!
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3822
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3823
supportsSharedLocks
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3824
    "return true, if the OS supports shared (i.e. multiple reader)
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3825
     file locking."
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3826
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3827
%{ /* NOCONTEXT */
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3828
#if defined(F_SETLK) && defined(F_RDLCK) && defined(F_WRLCK)
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3829
    RETURN (true);
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3830
#else
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3831
# if defined(LOCK_EX) && defined(LOCK_SH) && defined(LOCK_UN)
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3832
    RETURN (true);
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3833
# endif
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3834
#endif
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3835
%}.
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3836
    ^ false
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3837
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3838
    "
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3839
     OperatingSystem supportsNonBlockingFileLocks
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3840
    "
1621
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3841
!
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3842
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3843
unlockFD:aFileDescriptor
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3844
    "clear a file lock on the file represented by aFileDescriptor,
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3845
     which was previously aquired by #lockFD:.
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3846
     Return false, if the unlock failed 
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3847
     (which may happens when a wrong fd is passed, 
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3848
      no lock was set previously, or the systsem does not support locks).
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3849
     Notice, that not all OS's support file locks; 
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3850
     on some, this may simply be a no-op."
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3851
     
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3852
%{
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3853
    if (__isSmallInteger(aFileDescriptor)) {
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3854
	int fd = __intVal(aFileDescriptor);
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3855
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3856
	/*
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3857
	 * claus: sigh - each one has a different interface ...
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3858
	 */
1621
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3859
#if defined(F_SETLK)
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3860
	{
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3861
	    /*
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3862
	     * new fcntl(SETLK) interface;
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3863
	     * available on SYSV4 and Linux
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3864
	     */
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3865
	    struct flock flock;
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3866
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3867
	    flock.l_type = F_UNLCK;
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3868
	    flock.l_whence = 0;
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3869
	    flock.l_start = 0;
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3870
	    flock.l_len = 0;
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3871
	    if (fcntl(fd, F_SETLK, &flock) != -1) {
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3872
		RETURN (true);
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3873
	    }
1621
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3874
	}
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3875
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3876
#else /* no F_SETLK available */
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3877
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3878
# if defined(LOCK_EX) && defined(LOCK_UN)
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3879
	/*
1621
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3880
	 * BSD 4.3 advisory locks
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3881
	 */
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3882
	if (flock(fd, LOCK_UN) != -1) {
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3883
	    RETURN (true);
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3884
	}
1621
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3885
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3886
# else /* no flock available */
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3887
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3888
#  if defined(F_LOCK) && defined(F_UNLOCK)
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3889
	/* 
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3890
	 * SYSV3 advisory locks
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3891
	 */
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3892
	if (lockf(fd, F_UNLOCK, 0) != -1) {
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3893
	    RETURN (true);
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3894
	}
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3895
#  endif
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3896
# endif
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3897
#endif
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3898
    }
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3899
%}.
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3900
    ^ false
1615
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3901
! !
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3902
1799
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  3903
!OperatingSystem class methodsFor:'file queries'!
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3904
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3905
baseNameOf:aPathString
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3906
    "return the baseName of the argument, aPathString
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3907
     - thats the file/directory name without leading parent-dirs
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3908
     (i.e. OperatingSystem baseNameOf:'/usr/lib/st/file' -> 'file'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3909
       and OperatingSystem baseNameOf:'/usr/lib' -> lib).
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3910
     This method does not check if the path is valid 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3911
     (i.e. if these directories really exist & is readable)."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3912
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3913
    |prev index sep|
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3914
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3915
    sep := self fileSeparator.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3916
    ((aPathString size == 1) and:[(aPathString at:1) == sep]) ifTrue:[
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3917
	^ aPathString
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3918
    ].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3919
    prev := 1.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3920
    [true] whileTrue:[
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3921
	index := aPathString indexOf:sep startingAt:prev.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3922
	index == 0 ifTrue:[
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3923
	    ^ aPathString copyFrom:prev
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3924
	].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3925
	prev := index + 1
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3926
    ]
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3927
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3928
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3929
     OperatingSystem baseNameOf:'/fee/foo/bar'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3930
     OperatingSystem baseNameOf:'foo/bar'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3931
     OperatingSystem baseNameOf:'../../foo/bar'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3932
     OperatingSystem baseNameOf:'hello'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3933
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3934
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3935
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3936
caseSensitiveFilenames
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3937
    "return true, if the OS has caseSensitive file naming.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3938
     On MSDOS, this will return false. Since this is for Unix, we
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3939
     return true."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3940
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3941
    ^ true
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3942
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3943
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3944
compressPath:pathName
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3945
    "return the pathName compressed - that is, remove all ..-entries
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3946
     and . entries. This does not always (in case of symbolic links)
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3947
     return the true pathName and is therefore used as a fallback
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3948
     if realPath and popen failed."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3949
1858
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
  3950
    |names n "{ Class: SmallInteger }" |
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3951
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3952
    names := pathName 
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3953
		asCollectionOfSubstringsSeparatedBy:self fileSeparator.
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3954
    names := names asOrderedCollection.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3955
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3956
     cut off initial double-slashes
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3957
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3958
    [names startsWith:#('' '')] whileTrue:[
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3959
	names removeFirst.
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3960
    ].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3961
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3962
     cut off double-slashes at end
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3963
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3964
    [names endsWith:#('')] whileTrue:[
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3965
	names removeLast.
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3966
    ].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3967
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3968
     cut off current-dir at beginning
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3969
    "
1858
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
  3970
    n := names size.
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
  3971
    [(n >= 2) and:[names startsWith:#('.')]] whileTrue:[
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3972
	names removeFirst.
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3973
	n := n - 1.
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3974
    ].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3975
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3976
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3977
     cut off parent-dirs at end
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3978
    "
1858
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
  3979
    [(n > 2) 
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3980
     and:[(names endsWith:#('..'))
1858
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
  3981
     and:[((names at:(n - 1)) startsWith:'.') not ]]] whileTrue:[
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3982
	names removeLast; removeLast.
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3983
	n := n - 2.
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3984
    ].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3985
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3986
    ^ names asStringWith:self fileSeparator 
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3987
		    from:1
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3988
		    to:n
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3989
		    compressTabs:false final:nil 
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3990
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3991
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3992
     OperatingSystem compressPath:'./..'    
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3993
     OperatingSystem compressPath:'/foo/bar/baz/..'  
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3994
     OperatingSystem compressPath:'foo/bar/baz/..'  
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3995
     OperatingSystem compressPath:'foo/bar/baz/../'  
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3996
     OperatingSystem compressPath:'foo/bar/baz/..///' 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3997
     OperatingSystem compressPath:'///foo/bar/baz/..///' 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3998
    "
1858
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
  3999
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
  4000
    "Modified: 1.11.1996 / 20:13:48 / cg"
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4001
!
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4002
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4003
directoryNameOf:aPathString
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4004
    "return the directoryName of the argument, aPath
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4005
     - thats the name of the directory where aPath is
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4006
     (i.e. OperatingSystem directoryNameOf:'/usr/lib/st/file' -> '/usr/lib/st'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4007
       and OperatingSystem directoryNameOf:'/usr/lib' -> /usr').
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4008
     This method does not check if the path is valid
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4009
     (i.e. if these directories really exist & are readable)."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4010
1799
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  4011
    |last index sep sepString p|
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4012
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4013
    sep := self fileSeparator.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4014
    sepString := sep asString.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4015
    (aPathString = sepString) ifTrue:[
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4016
	"
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4017
	 the trivial '/' case
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4018
	"
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4019
	^ aPathString
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4020
    ].
1799
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  4021
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  4022
    p := aPathString.
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  4023
    [p endsWith:sepString] whileTrue:[
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4024
	(p = sepString) ifTrue:[
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4025
	    ^ p
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4026
	].
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4027
	p := p copyWithoutLast:1
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4028
    ].
1799
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  4029
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4030
    last := 1.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4031
    [true] whileTrue:[
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4032
	index := p indexOf:sep startingAt:(last + 1).
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4033
	index == 0 ifTrue:[
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4034
	    (last == 1) ifTrue:[
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4035
		(p startsWith:sepString) ifTrue:[
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4036
		    ^ sepString
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4037
		].
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4038
		^ '.'
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4039
	    ].
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4040
"
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4041
	    (p startsWith:sepString) ifFalse:[
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4042
		(p startsWith:('..' , sepString)) ifFalse:[
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4043
		    ^ './' , (p copyTo:(last - 1))
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4044
		]
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4045
	    ].
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4046
"
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4047
	    ^ p copyTo:(last - 1)
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4048
	].
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4049
	last := index.
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4050
    ]
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4051
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4052
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4053
     OperatingSystem directoryNameOf:'/fee/foo/bar'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4054
     OperatingSystem directoryNameOf:'foo/bar'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4055
     OperatingSystem directoryNameOf:'../../foo/bar'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4056
     OperatingSystem directoryNameOf:'bar'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4057
     OperatingSystem directoryNameOf:'/bar'
1799
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  4058
     OperatingSystem directoryNameOf:'/tmp' 
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  4059
     OperatingSystem directoryNameOf:'/tmp///' 
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  4060
     OperatingSystem directoryNameOf:'/bar///' 
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  4061
     OperatingSystem directoryNameOf:'/bar/'  
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  4062
     OperatingSystem directoryNameOf:'./bar'  
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  4063
     OperatingSystem directoryNameOf:'/./bar'  
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  4064
    "
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  4065
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  4066
    "Modified: 22.10.1996 / 18:53:47 / cg"
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4067
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4068
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4069
fileSeparator
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4070
    "return the character used to separate names in a path.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4071
     This character differs for MSDOS and other systems,
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4072
     (but those are currently not supported - so this is some
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4073
      preparation for the future)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4074
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4075
    ^ $/
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4076
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4077
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4078
idOf:aPathName
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4079
    "return the fileNumber (i.e. inode number) of a file.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4080
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4081
     Not all operatingSystems may provide this - on those that do not,
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4082
     some dummy id will be returned.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4083
     On unix, this information can be used to check for two files being 
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4084
     physically identical, even if found in different directories 
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4085
     (i.e. if they are hardLinked)."
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4086
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4087
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4088
     this could have been implemented as:
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4089
	(self infoOf:aPathName) at:#id 
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4090
     but for huge directory searches the code below is faster
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4091
    "
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4092
1104
219a06128193 removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents: 1084
diff changeset
  4093
%{
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4094
    struct stat buf;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4095
    int ret;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4096
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4097
    if (__isString(aPathName)) {
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4098
	__BEGIN_INTERRUPTABLE__
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4099
	do {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4100
	    ret = stat((char *) __stringVal(aPathName), &buf);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4101
	} while (ret < 0 && errno == EINTR);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4102
	__END_INTERRUPTABLE__
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4103
	if (ret >= 0) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4104
	    RETURN (__MKSMALLINT(buf.st_ino));
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4105
	}
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4106
	@global(LastErrorNumber) = __MKSMALLINT(errno);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4107
	RETURN (nil);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4108
    }
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4109
%}
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4110
.
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  4111
    ^ self primitiveFailed
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4112
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4113
    "OperatingSystem idOf:'/'"
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4114
!
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4115
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4116
infoOf:aPathName
1858
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
  4117
    "return some object filled with info for the file 'aPathName';
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
  4118
     the info (for which corresponding access methods are understood by
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
  4119
     the returned object) is:
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4120
	 type  - a symbol giving the files fileType
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4121
	 mode  - numeric access mode 
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4122
	 uid   - owners user id
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4123
	 gid   - owners group id
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4124
	 size  - files size
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4125
	 id    - files number (i.e. inode number)
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4126
	 accessed      - last access time (as osTime-stamp)
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4127
	 modified      - last modification time (as osTime-stamp)
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4128
	 statusChanged - last status change time (as osTime-stamp)
1858
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
  4129
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
  4130
     Some of the fields may be returned as nil on systems which do not provide
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
  4131
     all of the information.
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4132
     Return nil if such a file does not exist. 
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4133
     For symbolic links, the info of the pointed-to-file is returned;
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4134
     use #linkInfoOf: to get info about the link itself.
1858
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
  4135
    "
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4136
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4137
    |info type mode uid gid size id 
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  4138
     atime mtime ctime|
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4139
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4140
%{
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4141
    struct stat buf;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4142
    int ret;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4143
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4144
    if (__isString(aPathName)) {
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4145
	__BEGIN_INTERRUPTABLE__
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4146
	do {
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4147
	    ret = stat((char *) __stringVal(aPathName), &buf);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4148
	} while ((ret < 0) && (errno == EINTR));
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4149
	__END_INTERRUPTABLE__
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4150
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4151
	if (ret < 0) {
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4152
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4153
	    RETURN ( nil );
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4154
	}
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4155
	switch (buf.st_mode & S_IFMT) {
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4156
	    case S_IFDIR:
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4157
		type = @symbol(directory);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4158
		break;
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4159
	    case S_IFREG:
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4160
		type = @symbol(regular);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4161
		break;
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4162
#ifdef S_IFCHR
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4163
	    case S_IFCHR:
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4164
		type = @symbol(characterSpecial);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4165
		break;
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4166
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4167
#ifdef S_IFBLK
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4168
	    case S_IFBLK:
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4169
		type = @symbol(blockSpecial);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4170
		break;
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4171
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4172
#ifdef S_IFLNK
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4173
	    case S_IFLNK:
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4174
		type = @symbol(symbolicLink);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4175
		break;
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4176
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4177
#ifdef S_IFSOCK
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4178
	    case S_IFSOCK:
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4179
		type = @symbol(socket);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4180
		break;
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4181
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4182
#ifdef S_IFIFO
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4183
	    case S_IFIFO:
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4184
		type = @symbol(fifo);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4185
		break;
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4186
#endif
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4187
	    default:
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4188
		type = @symbol(unknown);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4189
		break;
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4190
	}
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4191
	mode = __MKSMALLINT(buf.st_mode & 0777);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4192
	uid = __MKSMALLINT(buf.st_uid);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4193
	gid = __MKSMALLINT(buf.st_gid);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4194
	size = __MKSMALLINT(buf.st_size);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4195
	id = __MKSMALLINT(buf.st_ino);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4196
	atime = __MKUINT(buf.st_atime);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4197
	mtime = __MKUINT(buf.st_mtime);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4198
	ctime = __MKUINT(buf.st_ctime);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4199
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4200
%}.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4201
    mode notNil ifTrue:[
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4202
	^ FileStatusInfo
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4203
	    type:type 
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4204
	    mode:mode 
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4205
	    uid:uid 
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4206
	    gid:gid 
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4207
	    size:size 
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4208
	    id:id 
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4209
	    accessed:(AbsoluteTime fromOSTime:(atime * 1000)) 
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4210
	    modified:(AbsoluteTime fromOSTime:(mtime * 1000)) 
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4211
	    statusChanged:(AbsoluteTime fromOSTime:(ctime * 1000))
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4212
	    path:nil
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4213
   ].
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  4214
   ^ self primitiveFailed
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4215
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4216
   "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4217
    OperatingSystem infoOf:'/'
1858
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
  4218
    (OperatingSystem infoOf:'/') uid
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
  4219
    (OperatingSystem infoOf:'/') accessed
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4220
   "
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4221
!
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4222
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4223
isDirectory:aPathName
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4224
    "return true, if 'aPathName' is a valid directory path name.
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4225
     (i.e. exists and is a directory).
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4226
     This also returns true for symbolic links pointing to a directory;
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4227
     if you need to check for this, use #linkInfo:."
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4228
1104
219a06128193 removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents: 1084
diff changeset
  4229
%{
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4230
    struct stat buf;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4231
    int ret;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4232
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4233
    if (__isString(aPathName)) {
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4234
	__BEGIN_INTERRUPTABLE__
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4235
	do {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4236
	    ret = stat((char *) __stringVal(aPathName), &buf);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4237
	} while ((ret < 0) && (errno == EINTR));
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4238
	__END_INTERRUPTABLE__
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4239
	if (ret < 0) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4240
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4241
	    RETURN ( false );
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4242
	}
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4243
	RETURN ( ((buf.st_mode & S_IFMT) == S_IFDIR) ? true : false);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4244
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4245
%}.
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  4246
    ^ self primitiveFailed
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4247
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4248
    "an alternative implementation would be:
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4249
	^ (self infoOf:aPathName) at:#type == #directory
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4250
    "
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4251
!
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4252
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4253
isExecutable:aPathName
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4254
    "return true, if the given file is executable.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4255
     For symbolic links, the pointed-to-file is checked."
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4256
1104
219a06128193 removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents: 1084
diff changeset
  4257
%{
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4258
    int ret;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4259
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4260
    if (__isString(aPathName)) {
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4261
	__BEGIN_INTERRUPTABLE__
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4262
	do {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4263
	    ret = access(__stringVal(aPathName), X_OK);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4264
	} while ((ret < 0) && (errno == EINTR));
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4265
	__END_INTERRUPTABLE__
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4266
	if (ret < 0) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4267
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4268
	}
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4269
	RETURN ( ((ret == 0) ? true : false) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4270
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4271
%}.
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  4272
    ^ self primitiveFailed
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4273
!
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4274
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4275
isReadable:aPathName
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4276
    "return true, if the file/dir 'aPathName' is readable.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4277
     For symbolic links, the pointed-to-file is checked."
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4278
1104
219a06128193 removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents: 1084
diff changeset
  4279
%{
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4280
    int ret;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4281
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4282
    if (__isString(aPathName)) {
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4283
	__BEGIN_INTERRUPTABLE__
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4284
	do {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4285
	    ret = access(__stringVal(aPathName), R_OK);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4286
	} while ((ret < 0) && (errno == EINTR));
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4287
	__END_INTERRUPTABLE__
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4288
	if (ret < 0) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4289
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4290
	}
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4291
	RETURN ( ((ret == 0) ? true : false) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4292
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4293
%}.
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  4294
    ^ self primitiveFailed
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4295
!
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4296
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4297
isSymbolicLink:aPathName
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4298
    "return true, if the given file is a symbolic link"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4299
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4300
    ^ (self linkInfoOf:aPathName) notNil
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4301
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4302
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4303
     OperatingSystem isSymbolicLink:'Make.proto'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4304
     OperatingSystem isSymbolicLink:'Makefile' 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4305
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4306
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4307
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4308
isValidPath:aPathName
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4309
    "return true, if 'aPathName' is a valid path name
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4310
     (i.e. the file or directory exists)"
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4311
1104
219a06128193 removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents: 1084
diff changeset
  4312
%{
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4313
    struct stat buf;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4314
    int ret;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4315
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4316
    if (__isString(aPathName) || __isSymbol(aPathName) ) {
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4317
	__BEGIN_INTERRUPTABLE__
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4318
	do {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  4319
	    ret = stat((char *) __stringVal(aPathName), &buf);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4320
	} while ((ret < 0) && (errno == EINTR));
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4321
	__END_INTERRUPTABLE__
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4322
	if (ret < 0) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  4323
	    OperatingSystem_LastErrorNumber = __MKSMALLINT(errno);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4324
	    RETURN (false);
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4325
	}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4326
	RETURN ( ret ? false : true );
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4327
    }
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  4328
%}.
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  4329
    ^ self primitiveFailed
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4330
!
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4331
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4332
isWritable:aPathName
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4333
    "return true, if the given file is writable.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4334
     For symbolic links, the pointed-to-file is checked."
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4335
1104
219a06128193 removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents: 1084
diff changeset
  4336
%{
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4337
    int ret;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4338
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4339
    if (__isString(aPathName)) {
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4340
	__BEGIN_INTERRUPTABLE__
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4341
	do {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4342
	    ret = access(__stringVal(aPathName), W_OK);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4343
	} while ((ret < 0) && (errno == EINTR));
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4344
	__END_INTERRUPTABLE__
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4345
	if (ret < 0) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4346
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4347
	}
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4348
	RETURN ( ((ret == 0) ? true : false) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4349
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4350
%}.
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  4351
    ^ self primitiveFailed
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4352
!
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4353
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4354
linkInfoOf:aPathName
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4355
    "return a dictionary filled with info for the file 'aPathName',
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4356
     IFF aPathName is a symbolic link. 
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4357
     If aPathName is invalid, or its NOT a symbolic link, nil is returned.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4358
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4359
     The contents of the dictionary gives info about the link itself,
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4360
     on contrast to #infoOf:, which returns the info of the pointed to file
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4361
     in case of a symbolic link."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4362
     
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  4363
    |info type mode uid gid size id atime mtime ctime path|
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4364
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4365
%{  /* STACK: 1200 */
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  4366
#ifdef S_IFLNK
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4367
    struct stat buf;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4368
    int ret;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4369
    char pathBuffer[1024];
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4370
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4371
    if (__isString(aPathName)) {
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4372
	__BEGIN_INTERRUPTABLE__
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4373
	do {
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4374
	    ret = lstat((char *) __stringVal(aPathName), &buf);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4375
	} while ((ret < 0) && (errno == EINTR));
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4376
	__END_INTERRUPTABLE__
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4377
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4378
	if (ret < 0) {
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4379
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4380
	    RETURN ( nil );
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4381
	}
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4382
	switch (buf.st_mode & S_IFMT) {
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4383
	    default:
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4384
		RETURN ( nil ); /* not a symbolic link */
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4385
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4386
	    case S_IFLNK:
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4387
		type = @symbol(symbolicLink);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4388
		break;
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4389
	}
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4390
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4391
	mode = __MKSMALLINT(buf.st_mode & 0777);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4392
	uid = __MKSMALLINT(buf.st_uid);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4393
	gid = __MKSMALLINT(buf.st_gid);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4394
	size = __MKSMALLINT(buf.st_size);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4395
	id = __MKSMALLINT(buf.st_ino);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4396
	atime = __MKUINT(buf.st_atime);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4397
	mtime = __MKUINT(buf.st_mtime);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4398
	ctime = __MKUINT(buf.st_ctime);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4399
	if ((ret = readlink((char *) __stringVal(aPathName), pathBuffer, sizeof(pathBuffer))) < 0) {
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4400
	    OperatingSystem_LastErrorNumber = __MKSMALLINT(errno);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4401
	    RETURN ( nil );
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4402
	} 
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4403
	pathBuffer[ret] = '\0';  /* readlink does not 0-terminate */
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4404
	path = __MKSTRING(pathBuffer);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4405
    }
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  4406
#else
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  4407
    RETURN ( nil );
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  4408
#endif
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4409
%}.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4410
    mode notNil ifTrue:[
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4411
	info := IdentityDictionary new.
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4412
	^ FileStatusInfo
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4413
	    type:type 
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4414
	    mode:mode 
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4415
	    uid:uid 
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4416
	    gid:gid 
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4417
	    size:size 
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4418
	    id:id 
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4419
	    accessed:(AbsoluteTime fromOSTime:(atime * 1000)) 
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4420
	    modified:(AbsoluteTime fromOSTime:(mtime * 1000)) 
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4421
	    statusChanged:(AbsoluteTime fromOSTime:(ctime * 1000))
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4422
	    path:path
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4423
   ].
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  4424
   ^ self primitiveFailed
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4425
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4426
   "
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4427
    OperatingSystem infoOf:'Make.proto'  
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4428
    OperatingSystem linkInfoOf:'Make.proto' 
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4429
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4430
    OperatingSystem infoOf:'resources/motif.style'   
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4431
    OperatingSystem linkInfoOf:'resources/motif.style' 
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4432
   "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4433
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4434
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4435
parentDirectoryName
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4436
    "return the name used to refer to parent directories.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4437
     In MSDOS, Unix and other systems this is '..', but maybe different
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4438
     for other systems.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4439
     (but those are currently not supported - so this is some
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4440
      preparation for the future)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4441
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4442
    ^ '..'
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4443
!
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4444
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4445
pathNameOf:pathName
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4446
    "return the pathName of the argument, aPathString,
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4447
     - thats the full pathname of the directory, starting at '/'.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4448
     This method needs the path to be valid
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4449
     (i.e. all directories must exist, be readable and executable).
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4450
     Notice: if symbolic links are involved, the result may look different
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4451
     from what you expect."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4452
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4453
    |p path command|
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4454
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4455
    "some systems have a convenient function for this ..."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4456
    path := self primPathNameOf:pathName.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4457
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4458
    path isNil ifTrue:[
2080
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4459
	(self isValidPath:pathName) ifFalse:[
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4460
	    p := pathName.
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4461
	    [(p size > 1)
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4462
	     and:[p endsWith:(self fileSeparator)]
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4463
	    ] whileTrue:[
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4464
		p := p copyWithoutLast:1.
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4465
	    ].
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4466
	    ^ p
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4467
	].
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4468
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4469
	(SlowFork==true or:[ForkFailed==true]) ifFalse:[
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4470
	    PipeStream openErrorSignal handle:[:ex |
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4471
		ForkFailed := true.
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4472
		'OS: cannot fork/popen' errorPrintNL.
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4473
		ex return.
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4474
	    ] do:[
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4475
		"have to fall back ..."
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4476
		command := 'cd ' , pathName , '; pwd'.
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4477
		p := PipeStream readingFrom:command.
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4478
	    ].
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4479
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4480
	    (p isNil or:[p atEnd]) ifTrue:[
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4481
		('OS: PipeStream for <' , command , '> failed') errorPrintNL.
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4482
	    ] ifFalse:[
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4483
		path := p nextLine.
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4484
		p close.
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4485
	    ].
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4486
	].
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4487
	path isNil ifTrue:[
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4488
	    path := pathName
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4489
	].
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4490
	(SlowFork==true or:[ForkFailed==true]) ifTrue:[
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4491
	    path := self compressPath:path
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4492
	]
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4493
    ].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4494
    ^ path.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4495
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4496
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4497
     OperatingSystem pathNameOf:'.'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4498
     OperatingSystem pathNameOf:'../smalltalk/../smalltalk'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4499
     OperatingSystem pathNameOf:'../../..'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4500
     OperatingSystem pathNameOf:'..'
1799
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  4501
     OperatingSystem pathNameOf:'/tmp////' 
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  4502
     OperatingSystem pathNameOf:'/foo/bar' 
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  4503
     OperatingSystem pathNameOf:'/foo/bar/'
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  4504
     OperatingSystem pathNameOf:'/foo/bar//'
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  4505
    "
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  4506
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  4507
    "Modified: 22.10.1996 / 17:59:19 / cg"
1991
6dc27b78da3e Fix pathNameOf: for systems not supporting primPathNameOf:
Stefan Vogel <sv@exept.de>
parents: 1987
diff changeset
  4508
    "Modified: 29.11.1996 / 18:02:12 / stefan"
359
claus
parents: 357
diff changeset
  4509
!
claus
parents: 357
diff changeset
  4510
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4511
primPathNameOf:pathName
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4512
    "return the pathName of the argument, aPathString,
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4513
     - thats the full pathname of the directory, starting at '/'.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4514
     This method here returns nil, if the OS does not provide a
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4515
     realPath library function.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4516
     Notice: if symbolic links are involved, the result may look different
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4517
     from what you expect."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4518
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4519
    |path|
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4520
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4521
    "some systems have a convenient function for this ..."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4522
%{  /* STACK: 16000 */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4523
#ifdef HAS_REALPATH
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4524
    char nameBuffer[MAXPATHLEN + 1];
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4525
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4526
    if (__isString(pathName)) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  4527
	if (realpath(__stringVal(pathName), nameBuffer)) {
1688
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  4528
	    RETURN ( __MKSTRING(nameBuffer) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4529
	}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4530
    }
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  4531
#else
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  4532
# ifdef WIN32
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  4533
    char nameBuffer[MAXPATHLEN + 1];
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  4534
    char *pFinal;
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  4535
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  4536
    if (__isString(pathName)) {
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  4537
      if (GetFullPathName(__stringVal(pathName), sizeof(nameBuffer),
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  4538
			  nameBuffer, &pFinal)) {
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  4539
	  RETURN ( __MKSTRING(nameBuffer) );
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  4540
      }
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  4541
    }
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  4542
# endif
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4543
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4544
%}.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4545
    ^ nil
359
claus
parents: 357
diff changeset
  4546
!
claus
parents: 357
diff changeset
  4547
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4548
timeOfLastAccess:aPathName
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4549
    "return the time, when the file was last accessed.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4550
     For nonexistent files, nil is returned."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4551
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4552
    "could be implemented as:
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  4553
	(self infoOf:aPathName) at:#accessed 
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  4554
    "
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  4555
    |osSeconds|
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4556
%{
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4557
    struct stat buf;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4558
    time_t mtime;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4559
    int ret;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4560
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4561
    if (__isString(aPathName)) {
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  4562
	__BEGIN_INTERRUPTABLE__
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  4563
	do {
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  4564
	    ret = stat((char *) __stringVal(aPathName), &buf);
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  4565
	} while (ret < 0 && errno == EINTR);
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  4566
	__END_INTERRUPTABLE__
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  4567
	if (ret < 0) {
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  4568
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  4569
	    RETURN (nil);
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  4570
	}
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  4571
	osSeconds = __MKUINT(buf.st_atime);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4572
    }
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  4573
%}.
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  4574
    osSeconds notNil ifTrue:[^ AbsoluteTime fromOSTime:(osSeconds * 1000)].
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  4575
    ^ self primitiveFailed
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4576
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4577
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4578
     OperatingSystem timeOfLastAccess:'/'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4579
    "
359
claus
parents: 357
diff changeset
  4580
!
claus
parents: 357
diff changeset
  4581
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4582
timeOfLastChange:aPathName
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4583
    "return the time, when the file was last changed. 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4584
     For nonexistent files, nil is returned."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4585
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4586
    "could be implemented as:
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  4587
	(self infoOf:aPathName) at:#modified
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  4588
    "
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  4589
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  4590
    |osSeconds|
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4591
%{
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4592
    struct stat buf;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4593
    int ret;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4594
    time_t mtime;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4595
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4596
    if (__isString(aPathName)) {
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  4597
	__BEGIN_INTERRUPTABLE__
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  4598
	do {
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  4599
	    ret = stat((char *) __stringVal(aPathName), &buf);
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  4600
	} while (ret < 0 && errno == EINTR);
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  4601
	__END_INTERRUPTABLE__
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  4602
	if (ret < 0) {
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  4603
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  4604
	    RETURN ( nil );
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  4605
	}
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  4606
	osSeconds = __MKUINT(buf.st_mtime);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4607
    }
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  4608
%}.
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  4609
    osSeconds notNil ifTrue:[^ AbsoluteTime fromOSTime:(osSeconds * 1000)].
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  4610
    ^ self primitiveFailed
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4611
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4612
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4613
     OperatingSystem timeOfLastChange:'/'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4614
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4615
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4617
typeOf:aPathName
1858
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
  4618
    "return the type of a file as a symbol; for nonexistent files,
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
  4619
     nil is returned.
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
  4620
     Notice: for symbolic links, the type of the pointed-to file is returned."
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4621
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4622
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4623
     this could have been implemented as:
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4624
	(self infoOf:aPathName) at:#type 
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4625
     but for huge directory searches the code below is faster
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4626
    "
359
claus
parents: 357
diff changeset
  4627
1104
219a06128193 removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents: 1084
diff changeset
  4628
%{
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4629
    struct stat buf;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4630
    int ret;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4631
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4632
    if (__isString(aPathName)) {
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4633
	__BEGIN_INTERRUPTABLE__
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4634
	do {
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4635
	    ret = stat((char *) __stringVal(aPathName), &buf);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4636
	} while (ret < 0 && errno == EINTR);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4637
	__END_INTERRUPTABLE__
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4638
	if (ret < 0) {
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4639
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4640
	    RETURN ( nil );
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4641
	}
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4642
	switch (buf.st_mode & S_IFMT) {
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4643
	    case S_IFDIR:
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4644
		RETURN ( @symbol(directory) );
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4645
	    case S_IFREG:
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4646
		RETURN ( @symbol(regular) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4647
#ifdef S_IFCHR
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4648
	    case S_IFCHR:
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4649
		RETURN ( @symbol(characterSpecial) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4650
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4651
#ifdef S_IFBLK
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4652
	    case S_IFBLK:
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4653
		RETURN ( @symbol(blockSpecial) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4654
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4655
#ifdef S_IFLNK
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4656
	    case S_IFLNK:
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4657
		RETURN ( @symbol(symbolicLink) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4658
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4659
#ifdef S_IFSOCK
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4660
	    case S_IFSOCK:
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4661
		RETURN ( @symbol(socket) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4662
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4663
#ifdef S_IFIFO
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4664
	    case S_IFIFO:
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4665
		RETURN ( @symbol(fifo) );
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4666
#endif
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4667
	    default:
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4668
		RETURN ( @symbol(unknown) );
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4669
	}
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4670
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4671
%}.
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  4672
    ^ self primitiveFailed
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4673
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4674
    "
1858
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
  4675
     OperatingSystem typeOf:'/'   
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
  4676
     OperatingSystem typeOf:'.'   
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4677
     OperatingSystem typeOf:'Make.proto' 
1858
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
  4678
     OperatingSystem typeOf:'resources/motif.style' 
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4679
    "
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4680
! !
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4681
1799
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  4682
!OperatingSystem class methodsFor:'interrupts & signals'!
63
1f0cdefb013f *** empty log message ***
claus
parents: 51
diff changeset
  4683
10
claus
parents: 5
diff changeset
  4684
blockInterrupts
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  4685
    "disable interrupt processing - if disabled, incoming
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  4686
     interrupts will be registered and handled as soon as
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  4687
     interrupts are reenabled by OperatingSystemclass>>unblockInterrupts.
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  4688
     Returns the previous blocking status i.e. true if interrupts
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  4689
     where already blocked. You need this information for proper
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  4690
     unblocking, in case of nested block/unblock calls."
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  4691
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  4692
%{  /* NOCONTEXT */
710
10d86ca4c4a6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 704
diff changeset
  4693
    RETURN ( __BLOCKINTERRUPTS() );
10
claus
parents: 5
diff changeset
  4694
%}
claus
parents: 5
diff changeset
  4695
!
claus
parents: 5
diff changeset
  4696
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4697
defaultSignal:signalNumber
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4698
    "revert to the default action on arrival of a (Unix-)signal.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4699
     Dont confuse Unix signals with smalltalk signals.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4700
     WARNING: for some signals, it is no good idea to revert to default;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4701
     for example, the default for SIGINT (i.e. ^C) is to exit; while the
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4702
     default for SIGQUIT (^ \) is to dump core.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4703
     Also, NOTICE that signal numbers are not portable between unix
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4704
     systems - use OperatingSystem sigXXX to get the numeric value for
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4705
     a signal."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4706
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4707
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4708
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4709
    if (__isSmallInteger(signalNumber)) {
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  4710
#ifdef SIG_DFL
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  4711
	signal(__intVal(signalNumber), SIG_DFL);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4712
	RETURN (self);
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  4713
#endif
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4714
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4715
%}.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4716
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4717
     this error is triggered on non-integer argument
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4718
    "
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  4719
    ^ self primitiveFailed
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4720
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4721
    "you better save a snapshot image before trying this ..."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4722
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4723
     'if you hit ^C now, Smalltalk will exit immediately' printNewline.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4724
     OperatingSystem defaultSignal:(OperatingSystem sigINT).
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4725
     1 to:1000000 do:[:i| ].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4726
     OperatingSystem enableSignal:(OperatingSystem sigINT).
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4727
     'normal ^C handling again.' printNewline
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4728
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4729
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4730
840
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  4731
disableChildSignalInterrupts
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  4732
    "disable childSignal interrupts 
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  4733
     (SIGCHLD, if the architecture supports it).
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  4734
     We have to set the signal back to default, because ignoring 
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  4735
     SIGCHLD breaks wait & co"
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  4736
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  4737
    ^ self defaultSignal:(self sigCHLD)
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  4738
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  4739
    "Created: 5.1.1996 / 15:45:28 / stefan"
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  4740
!
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  4741
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4742
disableIOInterruptsOn:fd
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4743
    "turn off IO interrupts for a filedescriptor"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4744
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4745
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4746
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4747
    int ret, flags, f;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4748
754
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4749
#if (defined(F_GETFL) && defined(F_SETFL) && defined(FASYNC)) || defined(SYSV4)
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4750
    if (__isSmallInteger(fd)) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  4751
	f = __intVal(fd);
754
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4752
# if defined(SYSV4)
759
908363ce8a32 interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents: 756
diff changeset
  4753
	ret = ioctl(f, I_SETSIG, 0);
754
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4754
# else /*! SYSV4*/
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4755
	flags = fcntl(f, F_GETFL, 0);
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4756
	/*
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4757
	 * if already clear, there is no need for this syscall ...
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4758
	 */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4759
	if (flags & FASYNC) {
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4760
	    ret = fcntl(f, F_SETFL, flags & ~FASYNC);
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4761
	    if (ret >= 0) ret = flags;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4762
	} else {
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4763
	    ret = flags;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4764
	}
754
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4765
# endif /* !SYSV4 */
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  4766
	RETURN ( __MKSMALLINT(ret) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4767
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4768
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4769
%}.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4770
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4771
     this error is triggered on non-integer argument
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4772
     or if the OS does not support IO interrupts.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4773
    "
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  4774
    ^ self primitiveFailed
10
claus
parents: 5
diff changeset
  4775
!
claus
parents: 5
diff changeset
  4776
63
1f0cdefb013f *** empty log message ***
claus
parents: 51
diff changeset
  4777
disableSignal:signalNumber
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  4778
    "disable (Unix-) signal processing for signalNumber.
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  4779
     Dont confuse Unix signals with smalltalk signals.
63
1f0cdefb013f *** empty log message ***
claus
parents: 51
diff changeset
  4780
     WARNING: for some signals, it is no good idea to disable
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  4781
     them; for example, disabling the SIGINT signal turns off ^C
63
1f0cdefb013f *** empty log message ***
claus
parents: 51
diff changeset
  4782
     handling.
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4783
     Also, NOTICE that signal numbers are not portable between unix
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4784
     systems - use OperatingSystem sigXXX to get the numeric value for
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4785
     a signal.
63
1f0cdefb013f *** empty log message ***
claus
parents: 51
diff changeset
  4786
     Use only for fully debugged stand alone applications."
1f0cdefb013f *** empty log message ***
claus
parents: 51
diff changeset
  4787
1f0cdefb013f *** empty log message ***
claus
parents: 51
diff changeset
  4788
%{  /* NOCONTEXT */
1f0cdefb013f *** empty log message ***
claus
parents: 51
diff changeset
  4789
252
  4790
    if (__isSmallInteger(signalNumber)) {
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  4791
	int sigNo = __intVal(signalNumber);
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  4792
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  4793
	if (sigNo == 0) {
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  4794
	    RETURN (self);
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  4795
	}
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  4796
#ifdef SIG_IGN
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  4797
	signal(sigNo, SIG_IGN);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  4798
	RETURN (self);
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  4799
#endif
63
1f0cdefb013f *** empty log message ***
claus
parents: 51
diff changeset
  4800
    }
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4801
%}.
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4802
    "
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4803
     this error is triggered on non-integer argument
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4804
    "
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  4805
    ^ self primitiveFailed
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4806
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4807
    "
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4808
     'now, ^C is totally ignored ...' printNewline.
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4809
     OperatingSystem disableSignal:(OperatingSystem sigINT).
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4810
     1 to:1000000 do:[:i| ].
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4811
     OperatingSystem enableSignal:(OperatingSystem sigINT).
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4812
     '^C handled again.' printNewline
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4813
    "
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4814
!
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4815
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4816
disableTimer
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  4817
    "disable timer interrupts.
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  4818
     WARNING: 
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  4819
	the system will not operate correctly with timer interrupts
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  4820
	disabled, because no scheduling or timeouts are possible."
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4821
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4822
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4823
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  4824
#if defined(WIN32)
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  4825
    KillTimer(NULL, w32TimerId);
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  4826
    w32TimerId = 0;
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  4827
    RETURN (true);
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  4828
#else
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  4829
# if defined(ITIMER_REAL)
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4830
    struct itimerval dt;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4831
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4832
    dt.it_interval.tv_sec = 0;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4833
    dt.it_interval.tv_usec = 0;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4834
    dt.it_value.tv_sec = 0;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4835
    dt.it_value.tv_usec = 0;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4836
    setitimer(ITIMER_REAL, &dt, 0);
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4837
    RETURN (true);
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  4838
# endif /* ITIMER_REAL */
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  4839
#endif
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4840
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4841
.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4842
    ^ false
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4843
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4844
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4845
disableUserInterrupts
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4846
    "disable userInterrupt processing;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4847
     when disabled, no ^C processing takes place.
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  4848
     WARNING:
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  4849
	 If at all, use this only for debugged stand-alone applications, since
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  4850
	 no exit to the debugger is possible with user interrupts disabled.
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  4851
	 We recommend setting up a handler for the signal instead of disabling it."
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  4852
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  4853
    self disableSignal:(self sigBREAK).
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  4854
    self disableSignal:(self sigINT).
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4855
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4856
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4857
enableAbortInterrupts
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4858
    "enable abort signalhandling, and make it a regular signalInterrupt.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4859
     (the default will dump core and exit - which is not a good idea for
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4860
      end-user applications ...).
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4861
     This is especially useful, if linked-in C-libraries call abort() ..."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4862
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  4863
    self enableSignal:(self sigABRT)
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4864
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4865
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4866
enableChildSignalInterrupts
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4867
    "enable childSignal interrupts 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4868
     (SIGCHLD, if the architecture supports it).
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  4869
     After enabling, these signals will send the message 
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4870
     'childSignalInterrupt' to the ChildSignalInterruptHandler object."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4871
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  4872
    self enableSignal:(self sigCHLD)
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4873
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4874
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4875
enableFpExceptionInterrupts
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4876
    "enable floating point exception interrupts (if the
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4877
     architecture supports it).
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  4878
     After enabling, fpu-exceptions will send the message 
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4879
     'fpuExceptionInterrupt' to the FPUExceptionInterruptHandler object."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4880
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  4881
    self enableSignal:(self sigFP)
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4882
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4883
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4884
enableHardSignalInterrupts
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4885
    "enable hard signal exception interrupts (trap, buserror & segm. violation).
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  4886
     After enabling, these exceptions will send the message 
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4887
     'signalInterrupt' to the SignalInterruptHandler object."
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4888
855
2de3c842c687 dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  4889
    "/ leads to trouble ...
2de3c842c687 dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  4890
"/    self enableSignal:(self sigPIPE).
2de3c842c687 dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  4891
2de3c842c687 dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  4892
    "/ ... better to ignore them, and let it be handled as a writeErrorSignal.
2de3c842c687 dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  4893
    self disableSignal:(self sigPIPE).
2de3c842c687 dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  4894
1808
58ed32d318d4 handle SIGILL like bus or segv
Claus Gittinger <cg@exept.de>
parents: 1799
diff changeset
  4895
    self enableSignal:(self sigILL).
640
be94dfc60eaa Anforderung von SA_SIGINFO in sigaction.
Stefan Vogel <sv@exept.de>
parents: 630
diff changeset
  4896
    self enableSignal:(self sigBUS).
be94dfc60eaa Anforderung von SA_SIGINFO in sigaction.
Stefan Vogel <sv@exept.de>
parents: 630
diff changeset
  4897
    self enableSignal:(self sigSEGV)
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4898
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4899
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4900
enableIOInterruptsOn:fd
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4901
    "turn on IO interrupts for a filedescriptor"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4902
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4903
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4904
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4905
    int ret, flags, f;
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  4906
#ifndef __signalIoInterrupt
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4907
    extern void __signalIoInterrupt();
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  4908
#endif
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4909
    static int firstCall = 1;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4910
754
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4911
#if (defined(F_GETFL) && defined(F_SETFL) && defined(FASYNC)) || defined(SYSV4)
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4912
/*
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4913
 * SIGIO/SIGPOLL - data available for I/O
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4914
 * (used to wake up waiting processes)
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4915
 */
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4916
#ifdef SIGIO
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4917
# define THESIGNAL SIGIO
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4918
#else
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4919
# ifdef SIGPOLL
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4920
#  define THESIGNAL SIGPOLL
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4921
# else
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4922
#  ifdef SIGURG
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4923
#   define THESIGNAL SIGURG
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4924
#  endif
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4925
# endif
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4926
#endif
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4927
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4928
    if (__isSmallInteger(fd)) {
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4929
	if (firstCall) {
762
cea705669628 ok, stefan was right: HAS_SIGACTION works
Claus Gittinger <cg@exept.de>
parents: 761
diff changeset
  4930
#ifdef HAS_SIGACTION
754
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4931
	    struct sigaction act;
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4932
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4933
	    /*
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4934
	     * Do not add SA_RESTART here. A signal can cause a
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4935
	     * thread switch, another thread can do a garbage collect
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4936
	     * and restarted system calls may write into old
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4937
	     * (collected) addresses.
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4938
	     */
1062
baa5827a7a40 Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents: 1060
diff changeset
  4939
baa5827a7a40 Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents: 1060
diff changeset
  4940
	    act.sa_flags = SA_SIGINFO; /* <- if you add more, remember dummys at the top */
754
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4941
	    sigemptyset(&act.sa_mask);
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4942
	    act.sa_handler = __signalIoInterrupt;
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4943
	    sigaction(THESIGNAL, &act, 0);
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4944
#else
766
9d6cc2cc834e igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents: 765
diff changeset
  4945
# ifdef HAS_SIGVEC
813
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  4946
	    struct sigvec vec;
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  4947
1062
baa5827a7a40 Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents: 1060
diff changeset
  4948
	    vec.sv_flags = SV_INTERRUPT;
813
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  4949
	    sigemptyset(&vec.sv_mask);
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  4950
	    vec.sv_handler = __signalIoInterrupt;
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  4951
	    sigvec(THESIGNAL, &vec, NULL);
766
9d6cc2cc834e igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents: 765
diff changeset
  4952
# else
754
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4953
	    signal(THESIGNAL, __signalIoInterrupt);
766
9d6cc2cc834e igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents: 765
diff changeset
  4954
# endif
754
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4955
#endif
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4956
	    firstCall = 0;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4957
	}
754
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4958
#undef THESIGNAL
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4959
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  4960
	f = __intVal(fd);
754
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4961
# if defined(SYSV4)
759
908363ce8a32 interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents: 756
diff changeset
  4962
	ret = ioctl(f, I_SETSIG, S_INPUT | S_HIPRI | S_ERROR | S_RDNORM | S_RDBAND | S_MSG | S_HANGUP);
754
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4963
# else /*! SYSV4*/
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4964
	flags = fcntl(f, F_GETFL, 0);
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4965
	/*
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4966
	 * if already set, there is no need for this syscall ...
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4967
	 */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4968
	if (flags & FASYNC) {
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4969
	    ret = flags;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4970
	} else {
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4971
	    ret = fcntl(f, F_SETFL, flags | FASYNC);
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4972
	    if (ret >= 0) ret = flags;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4973
	}
754
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4974
# endif /*!SYSV4*/
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  4975
	RETURN ( __MKSMALLINT(ret) );
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4976
    }
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4977
#endif
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4978
%}.
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4979
    "
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4980
     this error is triggered on non-integer argument
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4981
     or if the system does not support SIGIO
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4982
    "
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  4983
    ^ self primitiveFailed
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4984
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4985
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4986
enableQuitInterrupts
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4987
    "enable quitInterrupt (usually ^\) handling, and make it a userInterrupt.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4988
     (the default will dump core and exit - which is not a good idea for
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4989
      end-user applications ...)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4990
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  4991
    self enableSignal:(self sigQUIT)
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4992
!
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4993
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4994
enableSignal:signalNumber
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  4995
    "enable (Unix-)signal processing for signalNumber.
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  4996
     Dont confuse Unix signals with smalltalk signals.
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4997
     The signal will be delivered to one of the standard handlers
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4998
     (SIGINT, SIGQUIT, etc) or to a general handler, which
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4999
     sends #signalInterrupt:.
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5000
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5001
     NOTICE that signal numbers are not portable between unix
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5002
     systems - use OperatingSystem sigXXX to get the numeric value for
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5003
     a signal."
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5004
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5005
%{  /* NOCONTEXT */
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5006
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5007
#ifdef NSIG
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5008
# define SIG_LIMIT NSIG
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5009
#else
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5010
# ifdef SIGUSR2
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5011
#  define SIG_LIMIT SIGUSR2
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5012
# else
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5013
#  ifdef SIGUSR
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5014
#   define SIG_LIMIT SIGUSR
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5015
#  endif
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5016
# endif
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5017
#endif
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5018
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5019
#if defined(SIGPOLL) && !defined(SIGIO)
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5020
# define SIGIO SIGPOLL
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5021
#endif
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5022
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5023
#ifdef SIGCHLD
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5024
# define CHILD_SIGNAL   SIGCHLD
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5025
#else
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5026
# ifdef SIGCLD
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5027
#  define CHILD_SIGNAL  SIGCLD
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5028
# endif
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5029
#endif
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5030
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5031
    int sigNr;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5032
#if defined(SIGINT) || defined(SIGQUIT)
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5033
# ifndef __signalUserInterrupt
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5034
    extern void __signalUserInterrupt(SIGHANDLER_ARG);
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5035
# endif
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5036
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5037
#ifdef SIGFPE
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5038
# ifndef __signalFpExceptionInterrupt
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5039
    extern void __signalFpExceptionInterrupt(SIGHANDLER_ARG);
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5040
# endif
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5041
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5042
#ifdef SIGIO
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5043
# ifndef __signalIoInterrupt
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5044
    extern void __signalIoInterrupt(SIGHANDLER_ARG);
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5045
# endif
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5046
#endif
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5047
#ifdef CHILD_SIGNAL
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5048
# ifndef __signalChildInterrupt
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5049
    extern void __signalChildInterrupt(SIGHANDLER_ARG);
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5050
# endif
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5051
#endif
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5052
#ifdef SIGPIPE
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5053
# ifndef __signalPIPEInterrupt
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5054
    extern void __signalPIPEInterrupt(SIGHANDLER_ARG);
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5055
# endif
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5056
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5057
#ifdef SIGBUS
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5058
# ifndef __signalBUSInterrupt
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5059
    extern void __signalBUSInterrupt(SIGHANDLER_ARG);
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5060
# endif
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5061
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5062
#ifdef SIGSEGV
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5063
# ifndef __signalSEGVInterrupt
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5064
    extern void __signalSEGVInterrupt(SIGHANDLER_ARG);
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5065
# endif
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5066
#endif
1808
58ed32d318d4 handle SIGILL like bus or segv
Claus Gittinger <cg@exept.de>
parents: 1799
diff changeset
  5067
#ifdef SIGILL
58ed32d318d4 handle SIGILL like bus or segv
Claus Gittinger <cg@exept.de>
parents: 1799
diff changeset
  5068
# ifndef __signalTrapInterrupt
58ed32d318d4 handle SIGILL like bus or segv
Claus Gittinger <cg@exept.de>
parents: 1799
diff changeset
  5069
    extern void __signalTrapInterrupt(SIGHANDLER_ARG);
58ed32d318d4 handle SIGILL like bus or segv
Claus Gittinger <cg@exept.de>
parents: 1799
diff changeset
  5070
# endif
58ed32d318d4 handle SIGILL like bus or segv
Claus Gittinger <cg@exept.de>
parents: 1799
diff changeset
  5071
#endif
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5072
#ifdef SIGALRM
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5073
# ifndef WIN32
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5074
#  ifndef __signalTimerInterrupt
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5075
    extern void __signalTimerInterrupt(SIGHANDLER_ARG);
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5076
#  endif
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5077
# endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5078
#endif
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5079
#ifndef __signalInterrupt
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5080
    extern void __signalInterrupt(SIGHANDLER_ARG);
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5081
#endif
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5082
    void (*handler)(SIGHANDLER_ARG);
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5083
252
  5084
    if (__isSmallInteger(signalNumber)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  5085
     && ((sigNr = __intVal(signalNumber)) >= 0)
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5086
#ifdef SIG_LIMIT
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5087
     &&  (sigNr <= SIG_LIMIT)
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5088
#endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5089
    ) {
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5090
	/*
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5091
	 * standard signals are forced into standard handlers
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5092
	 * - all others go into general signalInterrupt
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5093
	 */
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5094
#if defined(SIGPOLL) && defined(SIGIO)
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5095
	if (sigNr == SIGPOLL)
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5096
	    sigNr = SIGIO;
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5097
#endif
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5098
	switch (sigNr) {
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5099
	    case 0:
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5100
		/* enabling a non-supported signal */
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5101
		RETURN (self);
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5102
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5103
#ifdef SIGBREAK
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5104
	    case SIGBREAK:
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5105
#endif
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5106
#ifdef SIGINT
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5107
	    case SIGINT:
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5108
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5109
#ifdef SIGQUIT
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5110
	    case SIGQUIT:
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5111
#endif
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5112
#if defined(SIGINT) || defined(SIGQUIT) || defined(SIGBREAK)
329
claus
parents: 322
diff changeset
  5113
		handler = __signalUserInterrupt;
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5114
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5115
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5116
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5117
#ifdef SIGFPE
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5118
	    case SIGFPE:
329
claus
parents: 322
diff changeset
  5119
		handler = __signalFpExceptionInterrupt;
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5120
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5121
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5122
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5123
#ifdef SIGPIPE
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5124
	    case SIGPIPE:
329
claus
parents: 322
diff changeset
  5125
		handler = __signalPIPEInterrupt;
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5126
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5127
#endif
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5128
#ifdef SIGBUS
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5129
	    case SIGBUS:
329
claus
parents: 322
diff changeset
  5130
		handler = __signalBUSInterrupt;
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5131
		break;
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5132
#endif
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5133
#ifdef SIGSEGV
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5134
	    case SIGSEGV:
329
claus
parents: 322
diff changeset
  5135
		handler = __signalSEGVInterrupt;
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5136
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5137
#endif
1982
8d4f97279e55 oops - SIGILL was never cought
Claus Gittinger <cg@exept.de>
parents: 1966
diff changeset
  5138
#ifdef SIGILL
8d4f97279e55 oops - SIGILL was never cought
Claus Gittinger <cg@exept.de>
parents: 1966
diff changeset
  5139
	    case SIGILL:
1808
58ed32d318d4 handle SIGILL like bus or segv
Claus Gittinger <cg@exept.de>
parents: 1799
diff changeset
  5140
		handler = __signalTrapInterrupt;
58ed32d318d4 handle SIGILL like bus or segv
Claus Gittinger <cg@exept.de>
parents: 1799
diff changeset
  5141
		break;
58ed32d318d4 handle SIGILL like bus or segv
Claus Gittinger <cg@exept.de>
parents: 1799
diff changeset
  5142
#endif
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5143
#ifdef SIGIO
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5144
	    case SIGIO:
329
claus
parents: 322
diff changeset
  5145
		handler = __signalIoInterrupt;
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5146
		break;
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5147
#endif
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5148
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5149
#ifdef CHILD_SIGNAL
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5150
	    case CHILD_SIGNAL:
329
claus
parents: 322
diff changeset
  5151
		handler = __signalChildInterrupt;
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5152
		break;
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5153
#endif
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5154
#ifdef SIGALRM
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5155
# ifndef WIN32
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5156
	    case SIGALRM:
329
claus
parents: 322
diff changeset
  5157
		handler = __signalTimerInterrupt;
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5158
		break;
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5159
# endif
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5160
#endif
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5161
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5162
	    default:
329
claus
parents: 322
diff changeset
  5163
		handler = __signalInterrupt;
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5164
		break;
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5165
	}
766
9d6cc2cc834e igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents: 765
diff changeset
  5166
9d6cc2cc834e igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents: 765
diff changeset
  5167
	{
762
cea705669628 ok, stefan was right: HAS_SIGACTION works
Claus Gittinger <cg@exept.de>
parents: 761
diff changeset
  5168
#ifdef HAS_SIGACTION
813
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  5169
	    struct sigaction act;
766
9d6cc2cc834e igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents: 765
diff changeset
  5170
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  5171
	    /*
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  5172
	     * Do not add SA_RESTART here. A signal can cause a
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  5173
	     * thread switch, another thread can do a garbage collect
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  5174
	     * and restarted system calls may write into old
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  5175
	     * (collected) addresses.
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  5176
	     */
1062
baa5827a7a40 Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents: 1060
diff changeset
  5177
baa5827a7a40 Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents: 1060
diff changeset
  5178
	    act.sa_flags = SA_SIGINFO; /* <- if you add more, remember dummys at the top */
766
9d6cc2cc834e igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents: 765
diff changeset
  5179
	    sigemptyset(&act.sa_mask);
9d6cc2cc834e igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents: 765
diff changeset
  5180
	    act.sa_handler = handler;
9d6cc2cc834e igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents: 765
diff changeset
  5181
	    sigaction(sigNr, &act, 0);
213
3b56a17534fd *** empty log message ***
claus
parents: 204
diff changeset
  5182
#else
766
9d6cc2cc834e igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents: 765
diff changeset
  5183
# ifdef HAS_SIGVEC
813
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  5184
	    struct sigvec vec;
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  5185
1062
baa5827a7a40 Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents: 1060
diff changeset
  5186
	    vec.sv_flags = SV_INTERRUPT;
813
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  5187
	    sigemptyset(&vec.sv_mask);
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  5188
	    vec.sv_handler = handler;
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  5189
	    sigvec(sigNr, &vec, NULL);
766
9d6cc2cc834e igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents: 765
diff changeset
  5190
# else
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5191
	    (void) signal(sigNr, handler);
766
9d6cc2cc834e igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents: 765
diff changeset
  5192
# endif
9d6cc2cc834e igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents: 765
diff changeset
  5193
#endif
9d6cc2cc834e igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents: 765
diff changeset
  5194
	}
213
3b56a17534fd *** empty log message ***
claus
parents: 204
diff changeset
  5195
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5196
	/*
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5197
	 * maybe, we should return the old enable-status
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5198
	 * as boolean here ...
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5199
	 */
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5200
	RETURN (self);
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5201
    }
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5202
%}.
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5203
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5204
    "
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5205
     this error is triggered on non-integer argument, or
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5206
     if the signal number is not in the valid range (1..NSIG)
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5207
    "
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  5208
    ^ self primitiveFailed
63
1f0cdefb013f *** empty log message ***
claus
parents: 51
diff changeset
  5209
!
1f0cdefb013f *** empty log message ***
claus
parents: 51
diff changeset
  5210
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5211
enableTimer:milliSeconds
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5212
    "trigger a timerInterrupt, to be signalled after some (real) time."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5213
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5214
%{  /* NOCONTEXT */
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5215
    int millis;
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5216
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5217
    millis = __intVal(milliSeconds);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5218
754
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  5219
#if defined(ITIMER_REAL)
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5220
    {
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5221
	static int firstCall = 1;
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5222
	struct itimerval dt;
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5223
#ifndef __signalTimerInterrupt
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5224
	extern void __signalTimerInterrupt(SIGHANDLER_ARG);
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5225
#endif
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5226
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5227
	if (firstCall) {
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5228
# ifdef HAS_SIGACTION
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5229
	    struct sigaction act;
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5230
1062
baa5827a7a40 Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents: 1060
diff changeset
  5231
	    act.sa_flags = SA_SIGINFO; /* <- if you add more, remember dummys at the top */
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5232
	    sigemptyset(&act.sa_mask);
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5233
	    act.sa_handler = __signalTimerInterrupt;
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5234
	    sigaction(SIGALRM, &act, 0);
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5235
# else
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5236
#  ifdef HAS_SIGVEC
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5237
	    struct sigvec vec;
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5238
1062
baa5827a7a40 Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents: 1060
diff changeset
  5239
	    vec.sv_flags = SV_INTERRUPT;
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5240
	    sigemptyset(&vec.sv_mask);
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5241
	    vec.sv_handler = __signalTimerInterrupt;
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5242
	    sigvec(SIGALRM, &vec, NULL);
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5243
#  else
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5244
	    signal(SIGALRM, __signalTimerInterrupt);
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5245
#  endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5246
# endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5247
	    firstCall = 0;
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5248
	}
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5249
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5250
	dt.it_interval.tv_sec = 0;
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5251
	dt.it_interval.tv_usec = 0;
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5252
	dt.it_value.tv_sec = millis / 1000;
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5253
	dt.it_value.tv_usec = (millis % 1000) * 1000;  
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5254
	setitimer(ITIMER_REAL, &dt, 0);
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5255
	RETURN (true);
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5256
    }
754
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  5257
#else
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5258
# ifdef WIN32
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5259
    {
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5260
	/*
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5261
	 * two mechanisms - which one to use ?
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5262
	 */
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5263
#  ifdef USE_TimerProc
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5264
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5265
	extern VOID CALLBACK __win32TimerProc(HWND, UINT, UINT, DWORD);
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  5266
	w32TimerId = SetTimer(NULL, 0, millis, __win32TimerProc);
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5267
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5268
#  else /* USE_TimeProc */
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5269
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5270
	extern void CALLBACK __win32TimeProc(UINT, UINT, DWORD, DWORD, DWORD, DWORD);
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  5271
	timeSetEvent(millis, 5, (LPTIMECALLBACK)__win32TimeProc, 0, TIME_ONESHOT);
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5272
#  endif
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  5273
	RETURN (true);
640
be94dfc60eaa Anforderung von SA_SIGINFO in sigaction.
Stefan Vogel <sv@exept.de>
parents: 630
diff changeset
  5274
    }
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5275
# endif /* WIN32 */
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5276
#endif /* ITIMER_REAL */
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5277
%}.
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5278
    ^ false
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5279
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5280
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5281
enableUserInterrupts
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5282
    "enable userInterrupt (^C) handling;
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  5283
     when enabled, ^C in the terminal window will send the message
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  5284
     'userInterrupt' to the UserInterruptHandler object."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5285
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5286
    self enableSignal:(self sigINT).
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5287
    self enableSignal:(self sigBREAK).
63
1f0cdefb013f *** empty log message ***
claus
parents: 51
diff changeset
  5288
!
1f0cdefb013f *** empty log message ***
claus
parents: 51
diff changeset
  5289
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5290
interruptPending
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5291
    "return true, if an interrupt is pending. The returned value is
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5292
     invalid if interrupts are not currently blocked, since otherwise 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5293
     the interrupt is usually already handled before arriving here,
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5294
     or may be served while returning from here."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5295
2117
460b14a6db96 added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
  5296
%{  /* NOCONTEXT */
460b14a6db96 added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
  5297
    extern OBJ __INTERRUPTPENDING();
460b14a6db96 added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
  5298
460b14a6db96 added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
  5299
    RETURN ( __INTERRUPTPENDING() );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5300
%}        
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5301
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5302
2117
460b14a6db96 added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
  5303
interruptsBlocked
460b14a6db96 added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
  5304
    "return true, if interrupt handling is currently disabled;
460b14a6db96 added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
  5305
     false otherwise."
460b14a6db96 added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
  5306
460b14a6db96 added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
  5307
%{  /* NOCONTEXT */
460b14a6db96 added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
  5308
    extern OBJ __INTERRUPTS_BLOCKED();
460b14a6db96 added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
  5309
460b14a6db96 added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
  5310
    RETURN ( __INTERRUPTS_BLOCKED() );
460b14a6db96 added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
  5311
%}
460b14a6db96 added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
  5312
!
460b14a6db96 added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
  5313
704
42cb0141808d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
  5314
killProcess:processId
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  5315
    "kill a unix process.
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5316
     The process terminates immediately and has no chance to perform any cleanup actions.
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5317
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5318
     WARNING: in order to avoid zombie processes (on unix),
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5319
	      you have to fetch the processes exitstatus with
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5320
	      OperatingSystem>>getStatusOfProcess:aProcessId."
704
42cb0141808d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
  5321
42cb0141808d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
  5322
    self sendSignal:(self sigKILL) to:processId.
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  5323
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  5324
    "Modified: 28.12.1995 / 15:06:18 / stefan"
704
42cb0141808d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
  5325
!
42cb0141808d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
  5326
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5327
nameForSignal:aSignalNumber
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5328
    "for a given Unix signalnumber, return a descriptive string"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5329
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5330
    aSignalNumber == self sigHUP    ifTrue:[^ 'hangup'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5331
    aSignalNumber == self sigINT    ifTrue:[^ 'interrupt'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5332
    aSignalNumber == self sigKILL   ifTrue:[^ 'kill'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5333
    aSignalNumber == self sigQUIT   ifTrue:[^ 'quit'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5334
    aSignalNumber == self sigILL    ifTrue:[^ 'illegal instruction'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5335
    aSignalNumber == self sigTRAP   ifTrue:[^ 'trap'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5336
    aSignalNumber == self sigABRT   ifTrue:[^ 'abort'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5337
    aSignalNumber == self sigIOT    ifTrue:[^ 'iot trap'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5338
    aSignalNumber == self sigEMT    ifTrue:[^ 'emt trap'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5339
    aSignalNumber == self sigFP     ifTrue:[^ 'fp exception'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5340
    aSignalNumber == self sigBUS    ifTrue:[^ 'bus error'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5341
    aSignalNumber == self sigSEGV   ifTrue:[^ 'segmentation violation'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5342
    aSignalNumber == self sigSYS    ifTrue:[^ 'bad system call'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5343
    aSignalNumber == self sigPIPE   ifTrue:[^ 'broken pipe'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5344
    aSignalNumber == self sigALRM   ifTrue:[^ 'alarm timer'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5345
    aSignalNumber == self sigTERM   ifTrue:[^ 'termination'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5346
    aSignalNumber == self sigSTOP   ifTrue:[^ 'stop'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5347
    aSignalNumber == self sigTSTP   ifTrue:[^ 'tty stop'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5348
    aSignalNumber == self sigCONT   ifTrue:[^ 'continue'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5349
    aSignalNumber == self sigCHLD   ifTrue:[^ 'child death'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5350
    aSignalNumber == self sigTTIN   ifTrue:[^ 'background tty input'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5351
    aSignalNumber == self sigTTOU   ifTrue:[^ 'background tty output'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5352
    aSignalNumber == self sigIO     ifTrue:[^ 'io available'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5353
    aSignalNumber == self sigXCPU   ifTrue:[^ 'cpu time expired'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5354
    aSignalNumber == self sigXFSZ   ifTrue:[^ 'file size limit'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5355
    aSignalNumber == self sigVTALRM ifTrue:[^ 'virtual alarm timer'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5356
    aSignalNumber == self sigPROF   ifTrue:[^ 'profiling timer'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5357
    aSignalNumber == self sigWINCH  ifTrue:[^ 'winsize changed'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5358
    aSignalNumber == self sigLOST   ifTrue:[^ 'resource lost'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5359
    aSignalNumber == self sigUSR1   ifTrue:[^ 'user signal 1'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5360
    aSignalNumber == self sigUSR2   ifTrue:[^ 'user signal 2'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5361
    aSignalNumber == self sigMSG    ifTrue:[^ 'HFT message'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5362
    aSignalNumber == self sigPWR    ifTrue:[^ 'power-fail'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5363
    aSignalNumber == self sigPRE    ifTrue:[^ 'programming exception'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5364
    aSignalNumber == self sigGRANT  ifTrue:[^ 'HFT access wanted'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5365
    aSignalNumber == self sigRETRACT ifTrue:[^ 'HFT access relinquish'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5366
    aSignalNumber == self sigSOUND   ifTrue:[^ 'HFT sound complete'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5367
    aSignalNumber == self sigDANGER  ifTrue:[^ 'low on paging space'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5368
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5369
    "notice: many systems map SIGPOLL and/or SIGUSR onto SIGIO
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5370
	     therefore, keep SIGIO always above the two below" 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5371
    aSignalNumber == self sigPOLL   ifTrue:[^ 'io available'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5372
    aSignalNumber == self sigURG    ifTrue:[^ 'urgent'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5373
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5374
    ^ 'unknown signal'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5375
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5376
    "
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5377
     OperatingSystem nameForSignal:9
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5378
     OperatingSystem nameForSignal:(OperatingSystem sigPOLL) 
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5379
    "
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5380
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5381
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5382
operatingSystemSignal:signalNumber
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5383
    "return the signal to be raised when an 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5384
     operatingSystem-signal occurs, or nil"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5385
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5386
    OSSignals notNil ifTrue:[
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5387
	^ OSSignals at:signalNumber ifAbsent:[nil]
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5388
    ].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5389
    ^ nil
10
claus
parents: 5
diff changeset
  5390
!
claus
parents: 5
diff changeset
  5391
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5392
operatingSystemSignal:signalNumber install:aSignal
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5393
    "install a signal to be raised when an operatingSystem-signal occurs"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5394
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5395
    OSSignals isNil ifTrue:[
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5396
	OSSignals := Array new:32
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5397
    ].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5398
    OSSignals at:signalNumber put:aSignal
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5399
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5400
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5401
sendSignal:signalNumber to:processId
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5402
    "send a unix signal to some process (maybe myself).
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5403
     Returns false if any error occurred, true otherwise.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5404
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5405
     Do not confuse UNIX signals with Smalltalk-Signals.
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5406
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5407
     WARNING: in order to avoid zombie processes (on unix),
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5408
	      you may have to fetch the processes exitstatus with
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5409
	      OperatingSystem>>getStatusOfProcess:aProcessId
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5410
	      if the signal terminates that process."
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5411
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5412
%{
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  5413
#ifndef MSDOS_LIKE
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5414
    if (__bothSmallInteger(signalNumber, processId)) {
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5415
	if (kill(__intVal(processId), __intVal(signalNumber)) < 0) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  5416
	    OperatingSystem_LastErrorNumber = __MKSMALLINT(errno);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5417
	    RETURN ( false );
216
a8abff749575 *** empty log message ***
claus
parents: 213
diff changeset
  5418
	}
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5419
	RETURN ( true );
10
claus
parents: 5
diff changeset
  5420
    }
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  5421
#endif
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5422
%}.
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  5423
    "/
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  5424
    "/ either invalid argument (non-integers)
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  5425
    "/ or not supported by OS
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  5426
    "/
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  5427
    ^ self primitiveFailed
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5428
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5429
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5430
startSpyTimer
63
1f0cdefb013f *** empty log message ***
claus
parents: 51
diff changeset
  5431
    "trigger a spyInterrupt, to be signalled after some short (virtual) time.
359
claus
parents: 357
diff changeset
  5432
     This is used by the old MessageTally for profiling.
63
1f0cdefb013f *** empty log message ***
claus
parents: 51
diff changeset
  5433
     Should be changed to use real profiling timer if available.
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5434
     On systems, where no virtual timer is available, use the real timer
359
claus
parents: 357
diff changeset
  5435
     (which is of course less correct).
claus
parents: 357
diff changeset
  5436
     OBSOLETE: the new messageTally runs as a high prio process, not using 
claus
parents: 357
diff changeset
  5437
	       spy interrupts."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5438
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5439
%{  /* NOCONTEXT */
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5440
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5441
#ifndef __spyInterrupt
329
claus
parents: 322
diff changeset
  5442
    extern void __spyInterrupt();
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5443
#endif
10
claus
parents: 5
diff changeset
  5444
#if defined(ITIMER_VIRTUAL)
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5445
    struct itimerval dt;
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5446
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
  5447
# ifdef SIGVTALRM
329
claus
parents: 322
diff changeset
  5448
    signal(SIGVTALRM, __spyInterrupt);
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
  5449
# else
329
claus
parents: 322
diff changeset
  5450
    signal(SIGALRM, __spyInterrupt);
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
  5451
# endif
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
  5452
348
claus
parents: 345
diff changeset
  5453
    dt.it_interval.tv_sec = 0;
claus
parents: 345
diff changeset
  5454
    dt.it_interval.tv_usec = 0;
claus
parents: 345
diff changeset
  5455
    dt.it_value.tv_sec = 0;
claus
parents: 345
diff changeset
  5456
    dt.it_value.tv_usec = 1000;   /* 1000 Hz */
claus
parents: 345
diff changeset
  5457
    setitimer(ITIMER_VIRTUAL, &dt, 0);
claus
parents: 345
diff changeset
  5458
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
  5459
    RETURN (true);
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5460
#endif
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5461
%}
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
  5462
.
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
  5463
    ^ false
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5464
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5465
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5466
stopSpyTimer
359
claus
parents: 357
diff changeset
  5467
    "stop spy timing - disable spy timer.
claus
parents: 357
diff changeset
  5468
     OBSOLETE: the new messageTally runs as a high prio process, not using 
claus
parents: 357
diff changeset
  5469
	       spy interrupts."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5470
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5471
%{  /* NOCONTEXT */
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5472
10
claus
parents: 5
diff changeset
  5473
#if defined(ITIMER_VIRTUAL)
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5474
    struct itimerval dt;
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5475
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5476
    dt.it_interval.tv_sec = 0;
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5477
    dt.it_interval.tv_usec = 0;
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5478
    dt.it_value.tv_sec = 0;
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5479
    dt.it_value.tv_usec = 0;
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5480
    setitimer(ITIMER_VIRTUAL, &dt, 0);
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
  5481
    RETURN (true);
10
claus
parents: 5
diff changeset
  5482
#endif
claus
parents: 5
diff changeset
  5483
%}
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
  5484
.
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
  5485
    ^ false
10
claus
parents: 5
diff changeset
  5486
!
claus
parents: 5
diff changeset
  5487
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  5488
terminateProcess:processId
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  5489
    "terminate a unix process.
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5490
     The process has a chance to do some cleanup.
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5491
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5492
     WARNING: in order to avoid zombie processes (on unix),
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5493
	      you may have to fetch the processes exitstatus with
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5494
	      OperatingSystem>>getStatusOfProcess:aProcessId."
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  5495
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  5496
    self sendSignal:(self sigTERM) to:processId.
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  5497
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  5498
    "Modified: 28.12.1995 / 15:05:37 / stefan"
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  5499
!
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  5500
1280
b7ae6227f48b Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents: 1247
diff changeset
  5501
terminateProcessGroup:processGroupId
b7ae6227f48b Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents: 1247
diff changeset
  5502
    "terminate a unix process group.
b7ae6227f48b Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents: 1247
diff changeset
  5503
     The process has a chance to do some cleanup.
b7ae6227f48b Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents: 1247
diff changeset
  5504
b7ae6227f48b Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents: 1247
diff changeset
  5505
     WARNING: in order to avoid zombie processes (on unix),
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  5506
	      you may have to fetch the processes exitstatus with
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  5507
	      OperatingSystem>>getStatusOfProcess:aProcessId."
1280
b7ae6227f48b Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents: 1247
diff changeset
  5508
b7ae6227f48b Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents: 1247
diff changeset
  5509
    self sendSignal:(self sigTERM) to:(processGroupId negated).
b7ae6227f48b Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents: 1247
diff changeset
  5510
b7ae6227f48b Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents: 1247
diff changeset
  5511
    "Modified: 28.12.1995 / 15:05:37 / stefan"
b7ae6227f48b Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents: 1247
diff changeset
  5512
    "Created: 23.4.1996 / 16:40:34 / stefan"
b7ae6227f48b Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents: 1247
diff changeset
  5513
!
b7ae6227f48b Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents: 1247
diff changeset
  5514
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5515
unblockInterrupts
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5516
    "enable interrupt processing - if any interrupts are pending,
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5517
     these will be handled immediately.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5518
     When unblocking interrupts, take care of nested block/unblock
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5519
     calls - you must only unblock after a blockcall if they where
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5520
     really not blocked before. See OperatingSystemclass>>blockInterrupts."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5521
%{
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5522
    __UNBLOCKINTERRUPTS();
1040
60e4c4bbbca2 return nil from unblockInterrupts (thats what the inlined code returns)
Claus Gittinger <cg@exept.de>
parents: 1034
diff changeset
  5523
    RETURN (nil);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5524
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5525
! !
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5526
1799
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  5527
!OperatingSystem class methodsFor:'misc'!
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5528
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5529
exit
710
10d86ca4c4a6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 704
diff changeset
  5530
    "shutdown smalltalk immediately - this method does not return.
10d86ca4c4a6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 704
diff changeset
  5531
     Return 'good'-status (0) to the parent unix process."
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5532
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5533
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5534
    __mainExit(0);
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5535
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5536
    "OperatingSystem exit - dont evaluate this"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5537
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5538
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5539
exit:exitCode
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5540
    "shutdown smalltalk immediately -
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5541
     returning an exit-code to the parent unix process."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5542
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5543
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5544
    int code = 1;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5545
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5546
    if (__isSmallInteger(exitCode)) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  5547
	code = __intVal(exitCode);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5548
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5549
    __mainExit(code);
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5550
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5551
    "OperatingSystem exit:1 - dont evaluate this"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5552
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5553
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5554
exitWithCoreDump
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5555
    "shutdown smalltalk immediately - dumping core.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5556
     This always returns 'bad'-status to the parent unix process.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5557
     Notice, that no cleanup is performed at all - you may have to
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5558
     manually remove any tempfiles.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5559
     Use this only for debugging ST/X itself"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5560
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5561
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5562
    abort();
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5563
%}
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5564
    "
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5565
     OperatingSystem exitWithCoreDump - dont evaluate this
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5566
    "
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5567
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5568
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5569
slowFork:aBoolean
1247
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
  5570
    "set/clear the `avoid-fork-if-possible-because-its-slow' flag.
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
  5571
     Only used internally on SYSV3 systems"
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
  5572
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5573
    SlowFork := aBoolean
1247
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
  5574
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
  5575
    "Modified: 22.4.1996 / 13:13:09 / cg"
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5576
! !
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5577
1799
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  5578
!OperatingSystem class methodsFor:'os queries'!
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5579
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5580
getCPUDefine
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5581
    "return a string which was used to identify this CPU type when STX was
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5582
     compiled, and which should be passed down when compiling methods.
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5583
     For example, on linux, this may be '-Di386'; on a vax, this would be '-Dvax'.
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5584
     This is normally not of interest to 'normal' users; however, it is passed
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5585
     down to the c-compiler when methods are incrementally compiled to machine code."
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5586
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5587
%{  /* NOCONTEXT */
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5588
#   ifndef CPU_DEFINE
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5589
#       define CPU_DEFINE "-DunknownCPU"
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5590
#   endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5591
1688
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  5592
    RETURN ( __MKSTRING(CPU_DEFINE));
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5593
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5594
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5595
     OperatingSystem getCPUDefine
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5596
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5597
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5598
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5599
getCPUType
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5600
    "return a string giving the type of machine we're running on.
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5601
     Here, the machine for which ST/X was compiled is returned
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5602
     (i.e. for all x86's, the same i386 is returned).
759
908363ce8a32 interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents: 756
diff changeset
  5603
     This may normally not be of any interest to you ..."
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5604
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5605
    |cpu|
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5606
    
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5607
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5608
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5609
#   ifdef vax
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5610
#    define CPU_STRING "vax"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5611
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5612
#   ifdef mips
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5613
#    define CPU_STRING "mips"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5614
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5615
#   ifdef i386
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5616
#    define CPU_STRING "i386"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5617
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5618
#   ifdef ns32k
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5619
#    define CPU_STRING "ns32k"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5620
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5621
#   ifdef mc68k
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5622
#    define CPU_STRING "mc68k"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5623
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5624
#   ifdef mc88k
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5625
#    define CPU_STRING "mc88k"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5626
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5627
#   ifdef sparc
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5628
#    define CPU_STRING "sparc"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5629
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5630
#   ifdef hppa
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5631
#    define CPU_STRING "hppa"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5632
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5633
#   ifdef rs6000
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5634
#    define CPU_STRING "rs6000"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5635
#   endif
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5636
#   ifdef powerPC
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5637
#    define CPU_STRING "powerPC"
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5638
#   endif
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5639
#   ifdef alpha
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5640
#    define CPU_STRING "alpha"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5641
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5642
#   ifdef transputer
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5643
#    define CPU_STRING "transputer"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5644
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5645
#   ifdef ibm370
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5646
#    define CPU_STRING "ibm370"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5647
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5648
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5649
#   ifndef CPU_STRING
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5650
#    define CPU_STRING "unknown"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5651
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5652
1688
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  5653
    cpu = __MKSTRING(CPU_STRING);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5654
#   undef CPU_STRING
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5655
%}.
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5656
    ^ cpu
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5657
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5658
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5659
     OperatingSystem getCPUType
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5660
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5661
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5662
    "examples: are we running on a ss-10/solaris ?"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5663
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5664
     (OperatingSystem getCPUType = 'sparc') 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5665
     and:[OperatingSystem getOSType = 'solaris']
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5666
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5667
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5668
    "or on a pc/solaris ?"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5669
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5670
     (OperatingSystem getCPUType = 'i386')
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5671
     and:[OperatingSystem getOSType = 'solaris']
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5672
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5673
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5674
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5675
getCommandOutputFrom:aCommand
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5676
    "execute a simple command (such as hostname) and
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5677
     return the commands output as a string"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5678
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5679
    |p result|
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5680
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5681
    ForkFailed ifFalse:[
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5682
	PipeStream openErrorSignal handle:[:ex |
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5683
	    ForkFailed := true.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5684
	    'OS: cannot fork/popen' errorPrintNL.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5685
	    ex return.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5686
	] do:[
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5687
	    p := PipeStream readingFrom:aCommand.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5688
	    p notNil ifTrue:[
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5689
		result := p nextLine.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5690
		p close
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5691
	    ]
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5692
	]
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5693
    ].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5694
    ^ result
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5695
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5696
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5697
getDomainName
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5698
    "return the domain this host is in.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5699
     Notice:
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  5700
	not all systems support this; on some, 'unknown' is returned."
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5701
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5702
    |name|
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5703
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5704
    DomainName notNil ifTrue:[
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  5705
	^ DomainName
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5706
    ].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5707
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5708
%{  /* STACK: 2048 */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5709
#if defined(HAS_GETDOMAINNAME)
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5710
    char buffer[128];
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5711
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5712
    if (getdomainname(buffer, sizeof(buffer)) == 0) {
1688
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  5713
	name = __MKSTRING(buffer);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5714
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5715
#else
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5716
# if defined(HAS_UNAME) && defined(HAS_UTS_DOMAINNAME)
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5717
    struct utsname ubuff;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5718
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5719
    if (uname(&ubuff) >= 0) {
1688
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  5720
	name = __MKSTRING(ubuff.domainname);
1433
8b2eacaea59c Getdomainname for Unixware.
Stefan Vogel <sv@exept.de>
parents: 1422
diff changeset
  5721
    }
8b2eacaea59c Getdomainname for Unixware.
Stefan Vogel <sv@exept.de>
parents: 1422
diff changeset
  5722
# else
8b2eacaea59c Getdomainname for Unixware.
Stefan Vogel <sv@exept.de>
parents: 1422
diff changeset
  5723
#  if defined(HAS_SYSINFO) && defined(SI_SRPC_DOMAIN)
8b2eacaea59c Getdomainname for Unixware.
Stefan Vogel <sv@exept.de>
parents: 1422
diff changeset
  5724
    char buffer[256];
8b2eacaea59c Getdomainname for Unixware.
Stefan Vogel <sv@exept.de>
parents: 1422
diff changeset
  5725
    int ret;
8b2eacaea59c Getdomainname for Unixware.
Stefan Vogel <sv@exept.de>
parents: 1422
diff changeset
  5726
8b2eacaea59c Getdomainname for Unixware.
Stefan Vogel <sv@exept.de>
parents: 1422
diff changeset
  5727
    if ((ret = sysinfo(SI_SRPC_DOMAIN, buffer, sizeof(buffer))) >= 0 && ret <= sizeof(buffer)) {
1688
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  5728
	name = __MKSTRING(buffer);
1433
8b2eacaea59c Getdomainname for Unixware.
Stefan Vogel <sv@exept.de>
parents: 1422
diff changeset
  5729
    }
8b2eacaea59c Getdomainname for Unixware.
Stefan Vogel <sv@exept.de>
parents: 1422
diff changeset
  5730
#  endif
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5731
# endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5732
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5733
%}.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5734
    name isNil ifTrue:[
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  5735
	name := self getEnvironment:'DOMAIN'.
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  5736
	name isNil ifTrue:[
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  5737
	    name := self getCommandOutputFrom:'domainname'
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  5738
	]
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5739
    ].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5740
    name isNil ifTrue:[
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  5741
	'OS: cannot find out domainname' errorPrintNL.
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  5742
	name := 'unknown'.
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5743
    ].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5744
    DomainName := name.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5745
    ^ name
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5746
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5747
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5748
     OperatingSystem getDomainName
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5749
    "
1433
8b2eacaea59c Getdomainname for Unixware.
Stefan Vogel <sv@exept.de>
parents: 1422
diff changeset
  5750
8b2eacaea59c Getdomainname for Unixware.
Stefan Vogel <sv@exept.de>
parents: 1422
diff changeset
  5751
    "Modified: 26.4.1996 / 10:04:54 / stefan"
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5752
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5753
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5754
getEnvironment:aStringOrSymbol
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5755
    "get an environment string"
10
claus
parents: 5
diff changeset
  5756
claus
parents: 5
diff changeset
  5757
%{  /* NOCONTEXT */
claus
parents: 5
diff changeset
  5758
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5759
    char *env;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5760
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5761
    if (__isString(aStringOrSymbol) || __isSymbol(aStringOrSymbol)) {
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  5762
#ifdef WIN32
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  5763
	char buff[512];
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  5764
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  5765
	env = NULL;
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  5766
	if (GetEnvironmentVariable(__stringVal(aStringOrSymbol),
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  5767
				   buff,
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  5768
				   sizeof(buff)-1)) {
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  5769
	    env = buff;
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  5770
	}
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  5771
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  5772
	env =  (char *)getenv(__stringVal(aStringOrSymbol));
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  5773
#endif
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5774
	if (env) {
1688
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  5775
	    RETURN ( __MKSTRING(env) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5776
	}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5777
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5778
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5779
.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5780
    ^ nil
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5781
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5782
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5783
     OperatingSystem getEnvironment:'LANG'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5784
     OperatingSystem getEnvironment:'LOGIN'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5785
     OperatingSystem getEnvironment:'HOME'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5786
     OperatingSystem getEnvironment:'NNTPSERVER'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5787
     OperatingSystem getEnvironment:'MAIL'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5788
     OperatingSystem getEnvironment:'PATH'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5789
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5790
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5791
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5792
getHostName
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5793
    "return the hostname we are running on - if there is
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5794
     a HOST environment variable, we are much faster here ...
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5795
     Notice:
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5796
	not all systems support this; on some, 'unknown' is returned."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5797
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5798
    |name|
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5799
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5800
    HostName notNil ifTrue:[
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5801
	^ HostName
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5802
    ].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5803
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5804
%{  /* STACK: 2048 */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5805
#if defined(HAS_GETHOSTNAME)
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5806
    char buffer[128];
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5807
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5808
    if (gethostname(buffer, sizeof(buffer)) == 0) {
1688
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  5809
	name = __MKSTRING(buffer);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5810
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5811
#else
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5812
# if defined(HAS_UNAME)
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5813
    struct utsname ubuff;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5814
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5815
    if (uname(&ubuff) >= 0) {
1688
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  5816
	name = __MKSTRING(ubuff.nodename);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5817
    }
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5818
# else
1702
777b74f65c7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  5819
#  if defined(HAS_SYSINFO) && defined(SI_HOSTNAME)
777b74f65c7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  5820
    char buffer[256];
777b74f65c7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  5821
    int ret;
777b74f65c7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  5822
 
777b74f65c7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  5823
    if ((ret = sysinfo(SI_HOSTNAME, buffer, sizeof(buffer))) >= 0 && ret <= sizeof(buffer)) {
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  5824
	name = __MKSTRING(buffer);
1702
777b74f65c7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  5825
    }
777b74f65c7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  5826
#  else
777b74f65c7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  5827
#   ifdef WIN32
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5828
    char buffer[128];
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5829
    int buffSize = sizeof(buffer);
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5830
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5831
    if (GetComputerName(buffer, &buffSize) == TRUE) {
1688
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  5832
	name = __MKSTRING(buffer);
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5833
    }
1702
777b74f65c7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  5834
#   endif
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5835
#  endif
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5836
# endif
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5837
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5838
%}.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5839
    name isNil ifTrue:[
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5840
	name := self getEnvironment:'HOST'.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5841
	name isNil ifTrue:[
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5842
	    name := self getCommandOutputFrom:'hostname'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5843
	]
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5844
    ].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5845
    name isNil ifTrue:[
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5846
	'OS: cannot find out hostname' errorPrintNL.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5847
	name := 'unknown'.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5848
    ].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5849
    HostName := name.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5850
    ^ name
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5851
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5852
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5853
     OperatingSystem getHostName
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5854
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5855
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5856
1034
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5857
getLocaleInfo
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5858
    "return a dictionary filled with values from the locale information;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5859
     Not all fields may be present, depending on the OS's setup and capabilities.
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5860
     Possible fields are:
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5861
	decimalPoint                    <String>
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5862
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5863
	thousandsSep                    <String>
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5864
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5865
	internationalCurrencySymbol     <String>
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5866
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5867
	currencySymbol                  <String>
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5868
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5869
	monetaryDecimalPoint            <String>
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5870
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5871
	monetaryThousandsSeparator      <String>
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5872
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5873
	positiveSign                    <String>
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5874
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5875
	negativeSign                    <String>
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5876
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5877
	internationalFractionalDigits   <Integer>
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5878
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5879
	fractionalDigits                <Integer>
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5880
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5881
	positiveSignPrecedesCurrencySymbol      <Boolean>
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5882
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5883
	negativeSignPrecedesCurrencySymbol      <Boolean>
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5884
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5885
	positiveSignSeparatedBySpaceFromCurrencySymbol  <Boolean>
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5886
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5887
	negativeSignSeparatedBySpaceFromCurrencySymbol  <Boolean>
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5888
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5889
	positiveSignPosition                            <Symbol>
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5890
							one of: #parenthesesAround, 
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5891
								#signPrecedes, 
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5892
								#signSuceeds, 
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5893
								#signPrecedesCurrencySymbol,
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5894
								#signSuceedsCurrencySymbol
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5895
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5896
	negativeSignPosition                            <like above>
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5897
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5898
     it is up to the application to deal with undefined values.
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5899
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5900
     Notice, that (for now), the system does not use this information;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5901
     it should be used by applications as required.
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5902
    "
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5903
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5904
    |info val|
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5905
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5906
    LocaleInfo notNil ifTrue:[
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5907
	"/ return the internal info; useful on systems which do not
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5908
	"/ support this.
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5909
	^ LocaleInfo
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5910
    ].
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5911
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5912
    info := IdentityDictionary new.
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5913
%{
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5914
    char *decimalPoint;         /* something like "." (US) or "," (german) */
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5915
    char *thousandsSep;         /* something like "," (US) or "." (german) */
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5916
    char *intCurrencySymbol;    /* international currency symbol; something like "USD "  "DM  " */
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5917
    char *currencySymbol;       /* local currency symbol;         something like "USD "  "DM  " */
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5918
    char *monDecimalPoint;      /* money: decimal point */
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5919
    char *monThousandsSep;      /* money: thousands sep */
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5920
    char *positiveSign;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5921
    char *negativeSign;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5922
    int   intFractDigits;       /* money: international digits after decPoint */
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5923
    int   fractDigits;          /* money: local digits after decPoint */
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5924
    int   csPosPrecedes;        /* money: 1 if currency symbol precedes a positive value; 0 if it sceeds */
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5925
    int   csNegPrecedes;        /* money: 1 if currency symbol precedes a negative value; 0 if it sceeds */
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5926
    int   csPosSepBySpace;      /* money: 1 if currency symbol should be separated by a space from a positive value; 0 if no space */
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5927
    int   csNegSepBySpace;      /* money: 1 if currency symbol should be separated by a space from a negative value; 0 if no space */
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5928
    int   csPosSignPosition;    /* money: 0: ()'s around the value & currency symbol */
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5929
    int   csNegSignPosition;    /*        1: sign precedes the value & currency symbol */
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5930
				/*        2: sign succeeds the value & currency symbol */
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5931
				/*        3: sign immediately precedes the currency symbol */
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5932
				/*        4: sign immediately suceeds the currency symbol */
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5933
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5934
#if defined(HAS_LOCALECONV)
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5935
    struct lconv *conf;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5936
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5937
    conf = localeconv();
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5938
    if (conf) {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5939
	decimalPoint = conf->decimal_point;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5940
	thousandsSep = conf->thousands_sep;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5941
	intCurrencySymbol = conf->int_curr_symbol;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5942
	currencySymbol = conf->currency_symbol;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5943
	monDecimalPoint = conf->mon_decimal_point;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5944
	monThousandsSep = conf->mon_thousands_sep;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5945
	positiveSign = conf->positive_sign;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5946
	negativeSign = conf->negative_sign;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5947
	intFractDigits = conf->int_frac_digits;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5948
	fractDigits = conf->frac_digits;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5949
	csPosPrecedes = conf->p_cs_precedes; 
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5950
	csNegPrecedes = conf->n_cs_precedes; 
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5951
	csPosSepBySpace = conf->p_sep_by_space; 
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5952
	csNegSepBySpace = conf->n_sep_by_space; 
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5953
	csPosSignPosition = conf->p_sign_posn;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5954
	csNegSignPosition = conf->n_sign_posn;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5955
    }
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5956
#else
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5957
    decimalPoint = (char *)0;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5958
    thousandsSep = (char *)0;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5959
    intCurrencySymbol = (char *)0;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5960
    currencySymbol = (char *)0;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5961
    monDecimalPoint = (char *)0;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5962
    monThousandsSep = (char *)0;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5963
    positiveSign =  (char *)0;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5964
    negativeSign =(char *)0;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5965
    intFractDigits = -1;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5966
    fractDigits = -1;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5967
    csPosPrecedes = -1; 
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5968
    csNegPrecedes = -1; 
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5969
    csPosSepBySpace = -1; 
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5970
    csNegSepBySpace = -1; 
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5971
    csPosSignPosition = -1;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5972
    csNegSignPosition = -1;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5973
#endif
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5974
    if (decimalPoint) {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5975
	val = __MKSTRING(decimalPoint);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5976
	__AT_PUT_(info, @symbol(decimalPoint), val);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5977
    }
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5978
    if (thousandsSep) {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5979
	val = __MKSTRING(thousandsSep);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5980
	__AT_PUT_(info, @symbol(thousandsSeparator), val);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5981
    }
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5982
    if (intCurrencySymbol) {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5983
	val = __MKSTRING(intCurrencySymbol);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5984
	__AT_PUT_(info, @symbol(internationCurrencySymbol), val);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5985
    }
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5986
    if (currencySymbol) {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5987
	val = __MKSTRING(currencySymbol);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5988
	__AT_PUT_(info, @symbol(currencySymbol), val);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5989
    }
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5990
    if (monDecimalPoint) {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5991
	val = __MKSTRING(monDecimalPoint);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5992
	__AT_PUT_(info, @symbol(monetaryDecimalPoint), val);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5993
    }
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5994
    if (monThousandsSep) {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5995
	val = __MKSTRING(monThousandsSep);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5996
	__AT_PUT_(info, @symbol(monetaryThousandsSeparator), val);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5997
    }
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5998
    if (positiveSign) {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5999
	val = __MKSTRING(positiveSign);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6000
	__AT_PUT_(info, @symbol(positiveSign), val);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6001
    }
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6002
    if (negativeSign) {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6003
	val = __MKSTRING(negativeSign);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6004
	__AT_PUT_(info, @symbol(negativeSign), val);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6005
    }
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6006
    if (intFractDigits >= 0) {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6007
	__AT_PUT_(info, @symbol(internationalFractionalDigits),  __MKSMALLINT(intFractDigits));
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6008
    }
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6009
    if (fractDigits >= 0) {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6010
	__AT_PUT_(info, @symbol(fractionalDigits),  __MKSMALLINT(fractDigits));
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6011
    }
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6012
    if (csPosPrecedes >= 0) {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6013
	if (csPosPrecedes == 0) {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6014
	    val = false;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6015
	} else {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6016
	    val = true;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6017
	}
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6018
	__AT_PUT_(info, @symbol(positiveSignPrecedesCurrencySymbol), val );
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6019
    }
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6020
    if (csNegPrecedes >= 0) {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6021
	if (csNegPrecedes == 0) {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6022
	    val = false;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6023
	} else {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6024
	    val = true;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6025
	}
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6026
	__AT_PUT_(info, @symbol(negativeSignPrecedesCurrencySymbol), val );
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6027
    }
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6028
    if (csPosSepBySpace >= 0) {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6029
	if (csPosSepBySpace == 0) {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6030
	    val = false;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6031
	} else {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6032
	    val = true;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6033
	}
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6034
	__AT_PUT_(info, @symbol(positiveSignSeparatedBySpaceFromCurrencySymbol), val);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6035
    }
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6036
    if (csNegSepBySpace >= 0) {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6037
	if (csNegSepBySpace == 0) {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6038
	    val = false;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6039
	} else {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6040
	    val = true;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6041
	}
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6042
	__AT_PUT_(info, @symbol(negativeSignSeparatedBySpaceFromCurrencySymbol), val);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6043
    }
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6044
    switch (csPosSignPosition) {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6045
	case 0:
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6046
	    val = @symbol(parenthesesAround);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6047
	    break;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6048
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6049
	case 1:
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6050
	    val = @symbol(signPrecedes);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6051
	    break;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6052
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6053
	case 2:
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6054
	    val = @symbol(signSuceeds);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6055
	    break;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6056
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6057
	case 3:
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6058
	    val = @symbol(signPrecedesCurrencySymbol);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6059
	    break;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6060
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6061
	case 4:
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6062
	    val = @symbol(signSuceedsCurrencySymbol);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6063
	    break;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6064
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6065
	default:
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6066
	    val = nil;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6067
    }
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6068
    if (val != nil) {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6069
	__AT_PUT_(info, @symbol(positiveSignPosition), val);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6070
    }
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6071
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6072
    switch (csNegSignPosition) {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6073
	case 0:
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6074
	    val = @symbol(parenthesesAround);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6075
	    break;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6076
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6077
	case 1:
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6078
	    val = @symbol(signPrecedes);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6079
	    break;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6080
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6081
	case 2:
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6082
	    val = @symbol(signSuceeds);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6083
	    break;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6084
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6085
	case 3:
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6086
	    val = @symbol(signPrecedesCurrencySymbol);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6087
	    break;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6088
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6089
	case 4:
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6090
	    val = @symbol(signSuceedsCurrencySymbol);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6091
	    break;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6092
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6093
	default:
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6094
	    val = nil;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6095
    }
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6096
    if (val != nil) {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6097
	__AT_PUT_(info, @symbol(negativeSignPosition), val);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6098
    }
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6099
%}.
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6100
    ^ info
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6101
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6102
    "
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6103
     OperatingSystem getLocaleInfo
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6104
    "
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6105
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6106
    "Created: 23.12.1995 / 14:19:20 / cg"
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6107
!
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6108
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6109
getOSDefine
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6110
    "return a string which was used to identify this machine when stx was
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6111
     compiled, and which should be passed down when compiling methods.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6112
     For example, on linux, this is '-DLINUX'."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6113
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6114
%{  /* NOCONTEXT */
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6115
#ifdef WIN32
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6116
# ifndef OS_DEFINE
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6117
#  define OS_DEFINE "-DWIN32"
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6118
# endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6119
#endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6120
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6121
#ifndef OS_DEFINE
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6122
# define OS_DEFINE "-DunknownOS"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6123
#endif
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6124
1688
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  6125
    RETURN ( __MKSTRING(OS_DEFINE));
1987
8249e9134622 win32 changes
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
  6126
8249e9134622 win32 changes
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
  6127
#undef OS_DEFINE
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6128
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6129
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6130
     OperatingSystem getOSDefine
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6131
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6132
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6133
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6134
getOSType
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6135
    "return a string giving the type of OS we're running on.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6136
     This can be used to adapt programs to certain environment
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6137
     differences (for example: mail-lock strategy ...)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6138
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6139
    |os|
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6140
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6141
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6142
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6143
#   ifdef MSDOS
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6144
#    define OS_STRING "msdos"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6145
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6146
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6147
#   ifdef WIN32
1987
8249e9134622 win32 changes
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
  6148
#    define OS_STRING "win32"
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6149
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6150
#   endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6151
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6152
#   ifdef MSWINDOWS
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6153
#    define OS_STRING "mswindows"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6154
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6155
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6156
#   ifdef NT
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6157
#    define OS_STRING "nt"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6158
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6159
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6160
#   ifdef VMS
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6161
#    define OS_STRING "vms"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6162
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6163
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6164
#   ifdef MVS
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6165
#    define OS_STRING "mvs"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6166
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6167
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6168
#   ifdef OS2
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6169
#    define OS_STRING "os2"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6170
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6171
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6172
#   ifdef sinix
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6173
#    define OS_STRING "sinix"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6174
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6175
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6176
#   ifdef ultrix
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6177
#    define OS_STRING "ultrix"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6178
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6179
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6180
#   ifdef sco
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6181
#    define OS_STRING "sco"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6182
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6183
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6184
#   ifdef hpux
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6185
#    define OS_STRING "hpux"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6186
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6187
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6188
#   ifdef LINUX
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6189
#    define OS_STRING "linux"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6190
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6191
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6192
#   ifdef sunos
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6193
#    define OS_STRING "sunos"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6194
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6195
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6196
#   ifdef solaris
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6197
#    define OS_STRING "solaris"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6198
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6199
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6200
#   ifdef IRIS
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6201
#    define OS_STRING "irix"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6202
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6203
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6204
#   ifdef aix
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6205
#    define OS_STRING "aix"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6206
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6207
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6208
#   ifdef realIX
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6209
#    define OS_STRING "realIX"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6210
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6211
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6212
    /*
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6213
     * no concrete info; become somewhat vague ...
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6214
     */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6215
#   ifndef OS_STRING
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6216
#    ifdef MACH
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6217
#     define OS_STRING "mach"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6218
#    endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6219
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6220
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6221
#   ifndef OS_STRING
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6222
#    ifdef BSD
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6223
#     define OS_STRING "bsd"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6224
#    endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6225
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6226
#    ifdef SYSV
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6227
#     ifdef SYSV3
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6228
#      define OS_STRING "sys5_3"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6229
#     else
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6230
#      ifdef SYSV4
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6231
#       define OS_STRING "sys5_4"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6232
#      else
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6233
#       define OS_STRING "sys5"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6234
#      endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6235
#     endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6236
#    endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6237
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6238
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6239
    /*
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6240
     * become very vague ...
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6241
     */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6242
#   ifndef OS_STRING
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6243
#    ifdef POSIX
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6244
#     define OS_STRING "posix"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6245
#    endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6246
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6247
#   ifndef OS_STRING
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6248
#    ifdef UNIX
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6249
#     define OS_STRING "unix"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6250
#    endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6251
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6252
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6253
#   ifndef OS_STRING
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6254
#    define OS_STRING "unknown"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6255
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6256
1688
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  6257
    os = __MKSTRING(OS_STRING);
1987
8249e9134622 win32 changes
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
  6258
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6259
#   undef OS_STRING
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6260
%}.
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6261
    ^ os
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6262
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6263
    "OperatingSystem getOSType"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6264
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6265
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6266
getProcessId
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6267
    "return the (unix-)processId"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6268
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6269
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6270
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6271
    int pid = 0;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6272
#ifdef UNIX_LIKE
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6273
    pid = getpid();
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  6274
#else
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  6275
# ifdef WIN32
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  6276
    pid = GetCurrentProcessId() & 0x3FFFFFFF;
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  6277
# endif
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6278
#endif
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  6279
    RETURN ( __MKSMALLINT(pid) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6280
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6281
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6282
     OperatingSystem getProcessId
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6283
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6284
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6285
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6286
getSystemID
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6287
    "if supported by the OS, return the systemID;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6288
     a unique per machine identification.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6289
     WARNING:
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6290
	not all systems support this; on some, 'unknown' is returned."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6291
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6292
%{  /* NO_CONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6293
#if defined(IRIX5) && !defined(HAS_GETHOSTID)
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6294
    char idBuffer[MAXSYSIDSIZE];
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6295
    int retVal;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6296
    OBJ arr;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6297
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6298
    if ((retVal = syssgi(SGI_SYSID, idBuffer)) == 0) {
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6299
	arr = __BYTEARRAY_UNINITIALIZED_NEW_INT(MAXSYSIDSIZE);
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6300
	bcopy(idBuffer, __ByteArrayInstPtr(arr)->ba_element, MAXSYSIDSIZE);
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6301
	RETURN (arr);
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6302
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6303
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6304
#if defined(HAS_GETHOSTID)
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6305
    int runningId;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6306
    OBJ arr;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6307
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6308
    runningId = gethostid();
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6309
    arr = __BYTEARRAY_UNINITIALIZED_NEW_INT(4);
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6310
    *(int *)(__ByteArrayInstPtr(arr)->ba_element) = runningId;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6311
    RETURN (arr);
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6312
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6313
%}.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6314
    ^ 'unknown'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6315
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6316
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6317
     OperatingSystem getSystemID
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6318
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6319
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6320
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6321
getSystemInfo
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6322
    "return info on the system weare running on.
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6323
     If the system supports the uname system call, that info is returned;
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6324
     otherwise, some simulated info is returned.
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6325
 
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6326
     WARNING:
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6327
       Do not depend on the amount and contents of the returned information, some
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6328
       systems may return more/less than others. Also, the contents depends on the
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6329
       OS, for example, linux returns 'ix86', while WIN32 returns 'x86'.
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6330
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6331
       This method is mainly provided to augment error reports with some system
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6332
       information. 
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6333
       (in case of system/version specific OS errors, conditional workarounds and patches
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  6334
	may be based upon this info)
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6335
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6336
     The returned info may (or may not) contain:
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6337
	#system -> some operating system identification (irix, Linux, nt, win32s ...) 
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6338
	#version -> OS version (some os version identification)
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6339
	#release -> OS release (3.5, 1.2.1 ...)
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6340
	#node   -> some host identification (hostname)
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6341
	#domain  -> domain name (hosts domain)
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6342
	#machine -> type of machine (i586, mips ...)
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6343
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6344
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6345
    |sys node rel ver mach dom mtyp brel info|
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6346
1060
119d45f975e1 increased getSystemInfos stack - just to make certain
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  6347
%{  /* STACK: 4096 */
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6348
#if defined(HAS_UNAME)
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6349
    struct utsname ubuff;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6350
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6351
    if (uname(&ubuff) >= 0) {
1688
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  6352
	sys  = __MKSTRING(ubuff.sysname);
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  6353
	node = __MKSTRING(ubuff.nodename);
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  6354
	rel  = __MKSTRING(ubuff.release);
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  6355
	ver  = __MKSTRING(ubuff.version);
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  6356
	mach = __MKSTRING(ubuff.machine);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6357
# ifdef HAS_UTS_DOMAINNAME
1688
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  6358
	dom  = __MKSTRING(ubuff.domainname);
1675
b4cd81adda85 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1666
diff changeset
  6359
# else
b4cd81adda85 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1666
diff changeset
  6360
#  if defined(HAS_GETDOMAINNAME)
b4cd81adda85 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1666
diff changeset
  6361
	{
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  6362
	    char buffer[128];
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  6363
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  6364
	    if (getdomainname(buffer, sizeof(buffer)) == 0) {
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  6365
		dom = __MKSTRING(buffer);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  6366
	    }
1675
b4cd81adda85 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1666
diff changeset
  6367
	}
b4cd81adda85 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1666
diff changeset
  6368
#  endif
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6369
# endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6370
    }
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6371
#else /* no uname */
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6372
# ifdef WIN32 
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6373
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6374
    char vsnBuffer[32];
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6375
    char *s;
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6376
    int winVer;
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6377
    DWORD vsn;
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6378
    SYSTEM_INFO sysInfo;
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6379
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6380
    vsn = GetVersion();
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6381
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6382
    if (HIWORD(vsn) & 0x8000) {
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6383
	s = "win32s";
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6384
    } else {
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  6385
	s = "nt";
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6386
    }
1688
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  6387
    sys = __MKSTRING(s);
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6388
    winVer = LOWORD(vsn);
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6389
    sprintf(vsnBuffer, "%d.%d", LOBYTE(winVer), HIBYTE(winVer));
1688
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  6390
    rel = __MKSTRING(vsnBuffer);
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6391
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6392
    GetSystemInfo(&sysInfo);
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6393
    if (sysInfo.dwProcessorType) {
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  6394
	sprintf(vsnBuffer, "%d", sysInfo.dwProcessorType);
1688
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  6395
	mach = __MKSTRING(vsnBuffer);
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6396
    }
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6397
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6398
# endif /* WIN32 */
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6399
#endif /* no uname */
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6400
%}.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6401
    sys isNil ifTrue:[
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6402
	sys := self getSystemType.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6403
    ].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6404
    node isNil ifTrue:[
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6405
	node := self getHostName
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6406
    ].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6407
    dom isNil ifTrue:[
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6408
	dom := self getDomainName
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6409
    ].
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6410
    mach isNil ifTrue:[
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6411
	mach := self getCPUType
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6412
    ].
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6413
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6414
    info := IdentityDictionary new.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6415
    info at:#system put:sys.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6416
    info at:#node put:node.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6417
    rel notNil ifTrue:[info at:#release put:rel].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6418
    ver notNil ifTrue:[info at:#version put:ver].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6419
    mach notNil ifTrue:[info at:#machine put:mach].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6420
    dom notNil ifTrue:[info at:#domain put:dom].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6421
    ^ info
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6422
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6423
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6424
     OperatingSystem getSystemInfo
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6425
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6426
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6427
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6428
getSystemType
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6429
    "return a string giving the type of system we're running on.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6430
     This is almost the same as getOSType, but the returned string
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6431
     is slightly different for some systems (i.e. iris vs. irix).
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6432
     Dont depend on this - use getOSType. I dont really see a point
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6433
     here ... 
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6434
     (except for slight differences between next/mach and other machs)"
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6435
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6436
    |sys|
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6437
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6438
%{
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6439
#   ifdef NEXT
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6440
#    define SYS_STRING "next"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6441
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6442
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6443
#   ifdef IRIS
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6444
#    define SYS_STRING "iris"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6445
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6446
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6447
#   ifdef WIN32 
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6448
#    define SYS_STRING  "win32"
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6449
#   endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6450
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6451
#   ifdef SYS_STRING
1688
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  6452
     sys = __MKSTRING(SYS_STRING);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6453
#    undef SYS_STRING
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6454
#   endif
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6455
%}.
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6456
    sys isNil ifTrue:[
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6457
	^ self getOSType
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6458
    ].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6459
    ^ sys
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6460
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6461
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6462
     OperatingSystem getSystemType
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6463
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6464
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6465
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6466
isBSDlike
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6467
    "return true, if the OS we're running on is a 'real' unix."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6468
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6469
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6470
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6471
#if defined(BSD) || defined(MACH) || defined(SYSV4)
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6472
    RETURN ( true );
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
  6473
#endif
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6474
%}.
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
  6475
    ^ false
10
claus
parents: 5
diff changeset
  6476
!
claus
parents: 5
diff changeset
  6477
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6478
isMSDOSlike
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6479
    "return true, if the OS we're running on is dos like 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6480
     (in contrast to unix-like)."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6481
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6482
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6483
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6484
#if defined(MSDOS_LIKE)
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6485
    RETURN ( true );
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6486
#endif
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6487
%}.
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6488
    ^ false
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6489
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6490
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6491
isMSWINDOWSlike
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6492
    "return true, if the OS we're running on is MS-Windows like."
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6493
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6494
%{  /* NOCONTEXT */
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6495
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6496
#if defined(WIN32)
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6497
    RETURN ( true );
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6498
#endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6499
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6500
%}.
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6501
    ^ false
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6502
!
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6503
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6504
isOS2like
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6505
    "return true, if the OS we're running on is OS2 like"
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6506
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6507
%{  /* NOCONTEXT */
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6508
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6509
#if defined(OS2)
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6510
    RETURN (true);
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6511
#endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6512
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6513
%}.
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6514
    ^ false
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6515
!
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6516
1034
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6517
isUNIXlike
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6518
    "return true, if the OS we're running on is a unix like."
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6519
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6520
%{  /* NOCONTEXT */
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6521
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6522
#if !defined(UNIX_LIKE)
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6523
    RETURN ( false );
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6524
#endif
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6525
%}.
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6526
    ^ true
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6527
!
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6528
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6529
maxFileNameLength
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6530
    "return the max number of characters in a filename.
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6531
     CAVEAT:
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  6532
	 Actually, the following is somewhat wrong - some systems
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  6533
	 support different sizezs, depending on the volume.
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  6534
	 We return a somewhat conservative number here."
10
claus
parents: 5
diff changeset
  6535
claus
parents: 5
diff changeset
  6536
%{  /* NOCONTEXT */
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6537
 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6538
    /*
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6539
     * XXX: newer systems provide a query function for this ... use it
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6540
     */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6541
#   if defined(BSD) || defined(SYSV4) || defined(LONGFILENAMES)
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6542
     RETURN ( __MKSMALLINT(255) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6543
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6544
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6545
#   ifdef realIX
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6546
      RETURN ( __MKSMALLINT(127) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6547
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6548
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6549
#   ifdef SYSV
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6550
      RETURN ( __MKSMALLINT(14) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6551
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6552
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6553
#   ifdef MSDOS
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6554
     RETURN ( __MKSMALLINT(9) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6555
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6556
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6557
#   ifdef WIN32
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6558
     /*
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6559
      * mhmh - depends on the filesystem type
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6560
      */
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6561
     RETURN ( __MKSMALLINT(9) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6562
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6563
%}.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6564
    "unix default"
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6565
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6566
    ^ 14
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6567
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6568
1034
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6569
setLocaleInfo:anInfoDictionary
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6570
    "set the locale information; if set, this oerrides the OS's settings.
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6571
     (internal in ST/X only - the OS's settings remain unaffected)
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6572
     See description of fields in #getLocaleInfo.
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6573
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6574
     Notice, that (for now), the system does not use this information;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6575
     it should be used by applications as required."
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6576
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6577
    LocaleInfo := anInfoDictionary
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6578
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6579
    "
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6580
     |d|
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6581
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6582
     d := IdentityDictionary new.
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6583
     d at:#decimalPoint                 put:'.'         .
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6584
     d at:#thousandsSeparator           put:','         .
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6585
     d at:#currencySymbol               put:'USD'       .
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6586
     d at:#monetaryDecimalPoint         put:'.'         .
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6587
     d at:#monetaryThousandsSeparator   put:'.'         .
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6588
     d at:#fractionalDigits             put:2           .
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6589
     d at:#positiveSign                 put:'+'         .
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6590
     d at:#negativeSign                 put:'-'         .
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6591
     d at:#positiveSignPrecedesCurrencySymbol put:true          .
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6592
     d at:#negativeSignPrecedesCurrencySymbol put:false         .
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6593
     OperatingSystem setLocaleInfo:d
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6594
    "
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6595
!
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6596
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6597
supportsIOInterrupts
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6598
    "return true, if the OS supports IO availability interrupts 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6599
     (i.e. SIGPOLL/SIGIO).
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6600
754
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  6601
     Currently, this mechanism does work for SYSV4 only ..."
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6602
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6603
%{  /* NOCONTEXT */
1062
baa5827a7a40 Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents: 1060
diff changeset
  6604
#if defined(SYSV4) && defined(USE_SIGIO) && 0
754
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  6605
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  6606
# if defined(SIGPOLL) || defined(SIGIO)
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  6607
#  if (defined(F_GETFL) && defined(F_SETFL) && defined(FASYNC)) || defined(SYSV4)
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  6608
   /*
765
93bdb4f0e095 no, SIGIO does not work on SGI ...
Claus Gittinger <cg@exept.de>
parents: 764
diff changeset
  6609
    * currently the only system where they work is unixware SYSV4
93bdb4f0e095 no, SIGIO does not work on SGI ...
Claus Gittinger <cg@exept.de>
parents: 764
diff changeset
  6610
    * (not even on SGI ...)
754
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  6611
    */
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  6612
#   if !defined(NEXT)
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  6613
     RETURN (true);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6614
#   endif
754
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  6615
#  endif
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  6616
# endif
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6617
10
claus
parents: 5
diff changeset
  6618
#endif
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6619
%}.
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
  6620
    ^ false
123
98771547e5ce OSSignals now here
claus
parents: 101
diff changeset
  6621
!
98771547e5ce OSSignals now here
claus
parents: 101
diff changeset
  6622
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6623
supportsNonBlockingIO
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6624
    "return true, if the OS supports nonblocking IO."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6625
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6626
%{  /* NOCONTEXT */
754
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  6627
#if defined(F_GETFL) && defined(F_SETFL) && defined(FNDELAY)
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6628
       RETURN (true);
754
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  6629
#endif
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6630
%}.
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6631
    ^ false
123
98771547e5ce OSSignals now here
claus
parents: 101
diff changeset
  6632
!
98771547e5ce OSSignals now here
claus
parents: 101
diff changeset
  6633
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6634
supportsSelect
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6635
    "return true, if the OS supports selecting on multiple
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6636
     filedescriptors via select."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6637
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6638
%{  /* NOCONTEXT */
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6639
#if defined(WIN32)
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6640
    RETURN (false);
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6641
#endif
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6642
#if defined(sco)
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6643
    /*
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6644
     * sco has a select, but its broken: always waiting 1 second
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6645
     */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6646
    RETURN(false);
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6647
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6648
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6649
.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6650
    ^ true
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6651
! !
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6652
1799
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  6653
!OperatingSystem class methodsFor:'shared memory access'!
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6654
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6655
shmAttach:id address:addr flags:flags
1247
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
  6656
    "low level entry to shmat()-system call.
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
  6657
     Not supported on all operatingSystems"
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
  6658
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6659
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6660
#ifdef WANT_SHM
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6661
    void *address, *shmaddr;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6662
    int shmflg, shmid;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6663
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6664
    if (__isSmallInteger(addr)
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6665
     && __bothSmallInteger(flags, id)) {
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6666
	shmaddr = (void *) __intVal(addr);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6667
	shmflg = __intVal(flags);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6668
	shmid = __intVal(id);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6669
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6670
	address = shmat(shmid, shmaddr, shmflg);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6671
	if (address != (void *)-1) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6672
	    RETURN (__MKEXTERNALBYTES(addr));
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6673
	}
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6674
	OperatingSystem_LastErrorNumber = __MKSMALLINT(errno);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6675
	RETURN (nil);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6676
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6677
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6678
%}.
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  6679
    ^ self primitiveFailed
1247
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
  6680
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
  6681
    "Modified: 22.4.1996 / 13:15:12 / cg"
370
claus
parents: 369
diff changeset
  6682
!
claus
parents: 369
diff changeset
  6683
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6684
shmDetach:addr
1247
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
  6685
    "low level entry to shmdt()-system call.
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
  6686
     Not supported on all operatingSystems"
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
  6687
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6688
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6689
#ifdef WANT_SHM
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6690
    void *shmaddr;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6691
    int rslt;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6692
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6693
    if (__isSmallInteger(addr)) {
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6694
	shmaddr = (void *) __intVal(addr);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6695
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6696
	rslt = shmdt(shmaddr);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6697
	if (rslt != -1) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6698
	    RETURN (true);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6699
	}
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6700
	OperatingSystem_LastErrorNumber = __MKSMALLINT(errno);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6701
	RETURN (false);
370
claus
parents: 369
diff changeset
  6702
    }
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6703
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6704
%}.
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  6705
    ^ self primitiveFailed
1247
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
  6706
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
  6707
    "Modified: 22.4.1996 / 13:15:03 / cg"
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6708
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6709
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6710
shmGet:key size:size flags:flags
1247
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
  6711
    "low level entry to shmget()-system call.
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
  6712
     This is not for public use and not supported with all operatingSystems.
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6713
     - use the provided wrapper class SharedExternalBytes instead."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6714
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6715
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6716
#ifdef WANT_SHM
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6717
    if (__bothSmallInteger(key, size)
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6718
     && __isSmallInteger(flags)) {
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6719
	int rslt;
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6720
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6721
	rslt = shmget(__intVal(key), __intVal(size), __intVal(flags));
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6722
	if (rslt != -1) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6723
	    RETURN (__MKSMALLINT(rslt));
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6724
	}
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6725
	OperatingSystem_LastErrorNumber = __MKSMALLINT(errno);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6726
	RETURN (nil);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6727
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6728
#endif
370
claus
parents: 369
diff changeset
  6729
%}.
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  6730
    ^ self primitiveFailed
1247
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
  6731
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
  6732
    "Modified: 22.4.1996 / 13:14:46 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  6733
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
  6734
1799
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  6735
!OperatingSystem class methodsFor:'time and date'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  6736
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6737
computeDatePartsOf:osTime for:aBlock
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6738
    "compute year, month and day from the OS time, osTime
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6739
     and evaluate the argument, a 3-arg block with these.
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6740
     Conversion is to localtime including any daylight saving adjustments."
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6741
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6742
    |year month day osSeconds|
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6743
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6744
    osSeconds := osTime // 1000.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  6745
%{
a27a279701f8 Initial revision
claus
parents:
diff changeset
  6746
    struct tm *tmPtr;
a27a279701f8 Initial revision
claus
parents:
diff changeset
  6747
    long t;
a27a279701f8 Initial revision
claus
parents:
diff changeset
  6748
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6749
    t = __longIntVal(osSeconds);
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6750
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  6751
    tmPtr = localtime(&t);
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  6752
    year = __MKSMALLINT(tmPtr->tm_year + 1900);
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  6753
    month = __MKSMALLINT(tmPtr->tm_mon + 1);
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  6754
    day = __MKSMALLINT(tmPtr->tm_mday);
810
9b3676f51220 mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents: 809
diff changeset
  6755
%}.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  6756
    aBlock value:year value:month value:day
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6757
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6758
    "
1510
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6759
     OperatingSystem computeDatePartsOf:0 for:[:y :m :d |
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  6760
	y printCR. m printCR. d printCR
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6761
     ]
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6762
    "
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6763
!
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6764
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6765
computeOSTimeFromYear:y month:m day:d hour:h minute:min seconds:s millis:millis
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6766
    "return the OS-dependent time for the given time and day. 
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6767
     The arguments are assumed to be in localtime including
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6768
     any daylight saving adjustings."
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6769
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6770
    |osSeconds|
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6771
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6772
%{
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6773
    struct tm tm;
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6774
    long t;
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6775
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6776
    if (__bothSmallInteger(y, m) 
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6777
     && __bothSmallInteger(d, h)
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6778
     && __bothSmallInteger(min, s)) {
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  6779
	tm.tm_hour = __intVal(h);
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  6780
	tm.tm_min = __intVal(min);
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  6781
	tm.tm_sec = __intVal(s);
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  6782
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  6783
	tm.tm_year = __intVal(y) - 1900;
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  6784
	tm.tm_mon = __intVal(m) - 1;
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  6785
	tm.tm_mday = __intVal(d);
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  6786
	tm.tm_isdst = -1;
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  6787
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  6788
	t = mktime(&tm);
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  6789
	osSeconds = __MKUINT(t);
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6790
    }
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6791
%}.
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6792
    osSeconds notNil ifTrue:[
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  6793
	^ osSeconds * 1000 + millis
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6794
    ].    
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6795
    ^ self primitiveFailed
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6796
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6797
    "
1510
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6798
     OperatingSystem computeOSTimeFromYear:1970 month:1 day:1 hour:0 minute:0 seconds:0 millis:0
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6799
    "
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6800
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6801
!
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6802
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6803
computeTimeAndDateFrom:osTime
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6804
    "given an OS-dependent time in osTime, return an Array
1511
823fcfbbb741 weekDay/yearDay start with0 in tm_ struct, but
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
  6805
     containing (full-) year, month, day, hour, minute and seconds,
1510
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6806
     offset to UTC, daylight savings time flag, milliseconds,
1511
823fcfbbb741 weekDay/yearDay start with0 in tm_ struct, but
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
  6807
     dayInYear (1..) and dayInWeek (1..).
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6808
     Conversion is to localtime including any daylight saving adjustments."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6809
1510
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6810
    |low hi year month day hours minutes seconds millis utcOffset 
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6811
     dst yDay wDay osSeconds ret|
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6812
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6813
    millis := osTime \\ 1000.
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6814
    osSeconds := osTime // 1000.
63
1f0cdefb013f *** empty log message ***
claus
parents: 51
diff changeset
  6815
%{
1f0cdefb013f *** empty log message ***
claus
parents: 51
diff changeset
  6816
    struct tm *tmPtr;
810
9b3676f51220 mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents: 809
diff changeset
  6817
    struct tm *gmTmPtr;
63
1f0cdefb013f *** empty log message ***
claus
parents: 51
diff changeset
  6818
    long t;
1f0cdefb013f *** empty log message ***
claus
parents: 51
diff changeset
  6819
2073
4c2bdfc668c9 NEXT changes (again)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  6820
#if defined(HAS_NO_TIMEZONE)
813
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  6821
#   define TIMEZONE     tmPtr->tm_gmtoff
811
6fbd6e7fdb74 mhmh - more ultrix kludges
Claus Gittinger <cg@exept.de>
parents: 810
diff changeset
  6822
#else
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6823
# ifdef MSDOS_LIKE
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6824
#   define TIMEZONE 0
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6825
# else
813
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  6826
#   define TIMEZONE     timezone
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6827
# endif
811
6fbd6e7fdb74 mhmh - more ultrix kludges
Claus Gittinger <cg@exept.de>
parents: 810
diff changeset
  6828
#endif
6fbd6e7fdb74 mhmh - more ultrix kludges
Claus Gittinger <cg@exept.de>
parents: 810
diff changeset
  6829
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6830
    t = __longIntVal(osSeconds);
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6831
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6832
    tmPtr = localtime(&t);
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6833
    hours = __MKSMALLINT(tmPtr->tm_hour);
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6834
    minutes = __MKSMALLINT(tmPtr->tm_min);
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6835
    seconds = __MKSMALLINT(tmPtr->tm_sec);
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6836
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6837
    year = __MKSMALLINT(tmPtr->tm_year + 1900);
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6838
    month = __MKSMALLINT(tmPtr->tm_mon + 1);
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6839
    day = __MKSMALLINT(tmPtr->tm_mday);
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6840
1511
823fcfbbb741 weekDay/yearDay start with0 in tm_ struct, but
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
  6841
    yDay = __MKSMALLINT(tmPtr->tm_yday+1);
1512
d4e6376dce78 weekDay fix (sunday is 0 in tm_wday)
Claus Gittinger <cg@exept.de>
parents: 1511
diff changeset
  6842
    wDay = __MKSMALLINT(tmPtr->tm_wday == 0 ? 7 : tmPtr->tm_wday);
1510
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6843
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6844
    if (tmPtr->tm_isdst == 0) {
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  6845
	dst = false;
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  6846
	utcOffset = __MKSMALLINT(TIMEZONE);
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6847
    } else {
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  6848
	dst = true;
800
067094efdaed use HAS_ALTZONE / HAS_DAYLIGHT
Claus Gittinger <cg@exept.de>
parents: 798
diff changeset
  6849
#ifdef HAS_ALTZONE
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  6850
	utcOffset = __MKSMALLINT(altzone);
800
067094efdaed use HAS_ALTZONE / HAS_DAYLIGHT
Claus Gittinger <cg@exept.de>
parents: 798
diff changeset
  6851
#else
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  6852
	utcOffset = __MKSMALLINT(TIMEZONE) + 3600;
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6853
#endif
63
1f0cdefb013f *** empty log message ***
claus
parents: 51
diff changeset
  6854
    }
241
6f30be88e314 *** empty log message ***
claus
parents: 234
diff changeset
  6855
%}.
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6856
    "I would love to have SELF-like inline objects ..."
1510
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6857
    ret := Array new:11.
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6858
    ret at:1 put:year.
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6859
    ret at:2 put:month.
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6860
    ret at:3 put:day.
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6861
    ret at:4 put:hours.
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6862
    ret at:5 put:minutes.
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6863
    ret at:6 put:seconds.
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6864
    ret at:7 put:utcOffset.
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6865
    ret at:8 put:dst.
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6866
    ret at:9 put:millis.
1510
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6867
    ret at:10 put:yDay.
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6868
    ret at:11 put:wDay.
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6869
    ^ ret
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6870
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6871
    "
1510
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6872
     OperatingSystem computeTimeAndDateFrom:0
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6873
    "
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6874
!
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6875
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6876
computeTimePartsOf:osTime for:aBlock
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6877
    "compute hours, minutes, seconds and milliseconds from the osTime 
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6878
     and evaluate the argument, a 4-arg block with these.
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6879
     Conversion is to localtime including any daylight saving adjustments."
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6880
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6881
    |hours minutes seconds millis osSeconds|
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6882
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6883
    osSeconds := osTime // 1000.
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6884
    millis := osTime \\ 1000.
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6885
%{
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6886
    struct tm *tmPtr;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6887
    long t;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6888
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6889
    t = __longIntVal(osSeconds);
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6890
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6891
    tmPtr = localtime(&t);
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  6892
    hours = __MKSMALLINT(tmPtr->tm_hour);
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  6893
    minutes = __MKSMALLINT(tmPtr->tm_min);
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  6894
    seconds = __MKSMALLINT(tmPtr->tm_sec);
810
9b3676f51220 mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents: 809
diff changeset
  6895
%}.
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6896
    aBlock value:hours value:minutes value:seconds value:millis
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6897
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6898
    "
1510
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6899
     OperatingSystem computeTimePartsOf:100 for:[:h :m :s :milli |
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  6900
	h printCR. m printCR. s printCR. millis printCR
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6901
     ]
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6902
    "
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6903
!
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6904
1510
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6905
computeUTCTimeAndDateFrom:osTime
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6906
    "given an OS-dependent time in osTime, return an Array
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6907
     containing year, month, day, hour, minute and seconds,
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6908
     offset to UTC, daylight savings time flag, milliseconds,
1511
823fcfbbb741 weekDay/yearDay start with0 in tm_ struct, but
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
  6909
     dayInYear (1..) and dayInWeek (1..).
1510
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6910
     Conversion is to UTC."
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6911
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6912
    |low hi year month day hours minutes seconds millis utcOffset 
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6913
     dst yDay wDay osSeconds ret|
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6914
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6915
    millis := osTime \\ 1000.
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6916
    osSeconds := osTime // 1000.
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6917
%{
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6918
    struct tm *tmPtr;
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6919
    struct tm *gmTmPtr;
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6920
    long t;
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6921
2073
4c2bdfc668c9 NEXT changes (again)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  6922
#if defined(HAS_NO_TIMEZONE)
1510
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6923
#   define TIMEZONE     tmPtr->tm_gmtoff
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6924
#else
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6925
# ifdef MSDOS_LIKE
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6926
#   define TIMEZONE 0
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6927
# else
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6928
#   define TIMEZONE     timezone
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6929
# endif
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6930
#endif
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6931
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6932
    t = __longIntVal(osSeconds);
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6933
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6934
    tmPtr = gmtime(&t);
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6935
    hours = __MKSMALLINT(tmPtr->tm_hour);
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6936
    minutes = __MKSMALLINT(tmPtr->tm_min);
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6937
    seconds = __MKSMALLINT(tmPtr->tm_sec);
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6938
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6939
    year = __MKSMALLINT(tmPtr->tm_year + 1900);
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6940
    month = __MKSMALLINT(tmPtr->tm_mon + 1);
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6941
    day = __MKSMALLINT(tmPtr->tm_mday);
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6942
1511
823fcfbbb741 weekDay/yearDay start with0 in tm_ struct, but
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
  6943
    yDay = __MKSMALLINT(tmPtr->tm_yday + 1);
1512
d4e6376dce78 weekDay fix (sunday is 0 in tm_wday)
Claus Gittinger <cg@exept.de>
parents: 1511
diff changeset
  6944
    wDay = __MKSMALLINT(tmPtr->tm_wday == 0 ? 7 : tmPtr->tm_wday);
1510
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6945
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6946
    if (tmPtr->tm_isdst == 0) {
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  6947
	dst = false;
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  6948
	utcOffset = __MKSMALLINT(TIMEZONE);
1510
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6949
    } else {
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  6950
	dst = true;
1510
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6951
#ifdef HAS_ALTZONE
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  6952
	utcOffset = __MKSMALLINT(altzone);
1510
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6953
#else
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  6954
	utcOffset = __MKSMALLINT(TIMEZONE) + 3600;
1510
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6955
#endif
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6956
    }
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6957
%}.
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6958
    "I would love to have SELF-like inline objects ..."
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6959
    ret := Array new:11.
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6960
    ret at:1 put:year.
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6961
    ret at:2 put:month.
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6962
    ret at:3 put:day.
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6963
    ret at:4 put:hours.
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6964
    ret at:5 put:minutes.
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6965
    ret at:6 put:seconds.
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6966
    ret at:7 put:utcOffset.
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6967
    ret at:8 put:dst.
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6968
    ret at:9 put:millis.
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6969
    ret at:10 put:yDay.
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6970
    ret at:11 put:wDay.
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6971
    ^ ret
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6972
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6973
    "
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6974
     OperatingSystem computeUTCTimeAndDateFrom:0
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6975
    "
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6976
!
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6977
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6978
computeUTCTimePartsOf:osTime for:aBlock
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6979
    "compute hours, minutes, seconds and milliseconds from the osTime 
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6980
     and evaluate the argument, a 4-arg block with these.
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6981
     Conversion is to UTC."
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6982
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6983
    |hours minutes seconds millis osSeconds|
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6984
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6985
    osSeconds := osTime // 1000.
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6986
    millis := osTime \\ 1000.
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6987
%{
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6988
    struct tm *tmPtr;
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6989
    long t;
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6990
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6991
    t = __longIntVal(osSeconds);
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6992
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6993
    tmPtr = gmtime(&t);
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6994
    hours = __MKSMALLINT(tmPtr->tm_hour);
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6995
    minutes = __MKSMALLINT(tmPtr->tm_min);
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6996
    seconds = __MKSMALLINT(tmPtr->tm_sec);
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6997
%}.
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6998
    aBlock value:hours value:minutes value:seconds value:millis
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6999
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7000
    "
1510
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  7001
     OperatingSystem computeUTCTimePartsOf:100 for:[:h :m :s :milli |
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7002
	h printCR. m printCR. s printCR. milli printCR
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7003
     ]
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7004
    "
275
a76029ddaa98 *** empty log message ***
claus
parents: 252
diff changeset
  7005
!
a76029ddaa98 *** empty log message ***
claus
parents: 252
diff changeset
  7006
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7007
getMillisecondTime
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7008
    "This returns the millisecond timers value. 
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7009
     The range is limited to 0..1fffffff (i.e. the SmallInteger range) to avoid
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7010
     LargeInteger arithmetic when doing timeouts and delays.
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  7011
     Since this value is wrapping around in regular intervals, this can only be used for 
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7012
     short relative time deltas.
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7013
     Use the millisecondTimeXXX:-methods to compare and add time deltas - these know about the wrap.
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7014
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7015
     BAD DESIGN:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7016
	This should be changed to return some instance of RelativeTime,
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7017
	and these computations moved there.
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7018
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7019
     Dont use this method in application code since it is an internal (private)
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7020
     interface. For compatibility with ST-80, use Time millisecondClockValue.
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7021
    "
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7022
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7023
%{  /* NOCONTEXT */
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7024
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7025
    long t;
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7026
#if !defined(HAS_GETTIMEOFDAY) && defined(SYSV) && defined(HZ)
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7027
    /* 
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7028
     * sys5 time
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7029
     */
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7030
    long ticks;
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7031
    struct tms tb;
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7032
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7033
    ticks = times(&tb);
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7034
    t = (ticks * 1000) / HZ;
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  7035
#else
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  7036
# ifdef WIN32
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  7037
    t = GetTickCount();
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  7038
# else
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  7039
#  ifdef MSDOS_LIKE
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  7040
    struct _timeb timebuffer;
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  7041
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  7042
    _ftime(&timebuffer);
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  7043
    t = (timebuffer.time * 1000) + timebuffer.millitm;
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  7044
#  else /* assume HAS_GETTIMEOFDAY */
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7045
    /*
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7046
     * bsd time
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7047
     */
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7048
    struct timeval tb;
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7049
    struct timezone tzb;
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7050
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7051
    gettimeofday(&tb, &tzb);
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7052
    t = tb.tv_sec*1000 + tb.tv_usec/1000;
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  7053
#  endif
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  7054
# endif
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  7055
#endif
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  7056
    RETURN ( __MKSMALLINT(t & 0x1FFFFFFF) );
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7057
%}
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7058
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7059
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7060
getOSTime
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7061
    "This returns the millisecond OS time.
2000
2c12eb609e05 commentary
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  7062
     The base of the returned value is not consistent across
2c12eb609e05 commentary
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  7063
     different OS's - some return the number of millis since jan, 1st 1970;
2c12eb609e05 commentary
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  7064
     others since 1900. The Time classes are prepared for this, and 
2c12eb609e05 commentary
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  7065
     convert as appropriate.
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7066
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7067
     Dont use this method in application code since it is an internal (private)
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7068
     interface. For compatibility with ST-80, use Time>>millisecondClockValue.
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7069
     or use instances of Time, Date or AbsoluteTime to work with.
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7070
    "
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7071
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7072
    |seconds millis|
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7073
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7074
%{
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7075
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7076
    long t;
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7077
#if !defined(HAS_GETTIMEOFDAY) && defined(SYSV) && defined(HZ)
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7078
    /* 
2000
2c12eb609e05 commentary
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  7079
     * sys5 time; we have to fake the information
2c12eb609e05 commentary
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  7080
     * the returned value is inexact.
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7081
     */
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7082
    int now;
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7083
    long ticks;
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7084
    struct tms tb;
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7085
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7086
    now = time(0);   /* seconds since 1970 ... */
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7087
    seconds = __MKUINT(now);
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7088
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7089
    ticks = times(&tb);
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7090
    t = (ticks * 1000) / HZ;
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7091
    t = t % 1000;
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7092
    millis = __MKSMALLINT(t);
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7093
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7094
#else
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7095
# ifdef MSDOS_LIKE
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7096
    struct _timeb timebuffer;
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7097
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7098
    _ftime(&timebuffer);
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7099
    seconds = __MKUINT(timebuffer.time);
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7100
    millis = __MKSMALLINT(timebuffer.millitm);
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7101
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7102
# else /* assume HAS_GETTIMEOFDAY */
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7103
    /*
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7104
     * bsd time
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7105
     */
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7106
    struct timeval tb;
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7107
    struct timezone tzb;
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7108
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7109
    gettimeofday(&tb, &tzb);
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7110
    seconds = __MKUINT(tb.tv_sec);
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7111
    millis = __MKSMALLINT(tb.tv_usec / 1000);
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7112
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7113
# endif
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7114
#endif
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7115
%}.
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7116
    ^ (seconds * 1000) + millis
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7117
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7118
    "
1510
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  7119
     OperatingSystem getOSTime printCR.
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7120
     Delay waitForSeconds:0.2.
1510
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  7121
     OperatingSystem getOSTime printCR.
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7122
    "
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7123
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7124
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7125
maximumMillisecondTimeDelta
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7126
    "this returns the maximum delta supported by millisecondCounter
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7127
     based methods. The returned value is half the value at which the
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7128
     timer wraps."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7129
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7130
%{  /* NOCONTEXT */
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  7131
    RETURN ( __MKSMALLINT(0x0FFFFFFF) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7132
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7133
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7134
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7135
millisecondDelay:millis
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7136
    "delay execution for millis milliseconds or until the next event
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7137
     arrives.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7138
     All lower priority threads will also sleep for the duration, 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7139
     interrupts (and therefore, higher prio processes) are
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7140
     still handled. 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7141
     Better use a Delay, to only delay the calling thread.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7142
     (however, a delay cannot be used in the event handler or scheduler)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7143
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7144
    |now then delta|
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7145
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7146
%{  /* NOCONTEXT */
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7147
#ifdef WIN32
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7148
    int t = __intVal(millis);
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7149
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7150
    if (t) {
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  7151
	Sleep(t);
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7152
    }
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7153
    RETURN (self);
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7154
#endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7155
%}.
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7156
 
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7157
    now := OperatingSystem getMillisecondTime.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7158
    then := OperatingSystem millisecondTimeAdd:now and:millis.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7159
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7160
    [OperatingSystem millisecondTime:then isAfter:now] whileTrue:[
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7161
	delta := OperatingSystem millisecondTimeDeltaBetween:then and:now.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7162
	self selectOnAnyReadable:nil writable:nil exception:nil withTimeOut:delta.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7163
	now := OperatingSystem getMillisecondTime.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7164
    ]
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7165
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7166
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7167
     OperatingSystem millisecondDelay:2000
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7168
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7169
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7170
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7171
millisecondTime:msTime1 isAfter:msTime2
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7172
    "return true if msTime1 is after msTime2, false if not.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7173
     The two arguments are supposed to be millisecond times 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7174
     (such as returned getMillisecondTime) which wrap at 16r1FFFFFFF.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7175
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7176
     This should really be moved to some RelativeTime class."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7177
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7178
    (msTime1 > msTime2) ifTrue:[
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7179
	((msTime1 - msTime2) >= 16r10000000) ifTrue:[
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7180
	    ^ false
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7181
	].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7182
	^ true
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7183
    ].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7184
    ((msTime2 - msTime1) > 16r10000000) ifTrue:[
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7185
	^ true
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7186
    ].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7187
    ^ false
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7188
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7189
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7190
millisecondTimeAdd:msTime1 and:msTime2
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7191
    "Add two millisecond times (such as returned getMillisecondTime).
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7192
     The returned value is msTime1 + msTime2 where a wrap occurs at:16r1FFFFFFF.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7193
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7194
     This should really be moved to some RelativeTime class."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7195
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7196
    |sum|
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7197
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7198
    sum := msTime1 + msTime2.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7199
    (sum > 16r1FFFFFFF) ifTrue:[^ sum - 16r20000000].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7200
    (sum < 0) ifTrue:[^ sum + 16r20000000].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7201
    ^ sum
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7202
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7203
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7204
millisecondTimeDeltaBetween:msTime1 and:msTime2
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7205
    "subtract two millisecond times (such as returned getMillisecondTime)
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7206
     and return the difference. Since milli-times wrap (at 16r01FFFFFFF), 
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7207
     some special handling is built-in here.
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7208
     The returned value is msTime1 - msTime2. The returned value is invalid
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7209
     if the delta is >= 0x10000000.
63
1f0cdefb013f *** empty log message ***
claus
parents: 51
diff changeset
  7210
810
9b3676f51220 mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents: 809
diff changeset
  7211
     This should really be moved to some RelativeTime class;
9b3676f51220 mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents: 809
diff changeset
  7212
     better yet: create a subclass of Integer named LimitedRangeInteger."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7213
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7214
    (msTime1 > msTime2) ifTrue:[
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7215
	^ msTime1 - msTime2
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7216
    ].
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7217
    ^ msTime1 + 16r10000000 - msTime2
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7218
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7219
    "
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7220
     OperatingSystem millisecondTimeAdd:16r0FFFFFFF and:1   
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7221
     OperatingSystem millisecondTimeAdd:16r0FFFFFFF and:(16 / 3)  
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7222
     OperatingSystem millisecondTimeAdd:16r0FFFFFFF and:1000   
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7223
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7224
     OperatingSystem millisecondTimeDeltaBetween:0 and:16r0FFFFFFF  
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7225
     OperatingSystem millisecondTimeDeltaBetween:(13/3) and:16r0FFFFFFF     
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7226
     OperatingSystem millisecondTimeDeltaBetween:999 and:16r0FFFFFFF       
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7227
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7228
     OperatingSystem millisecondTime:0 isAfter:16r0FFFFFFF    
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7229
     OperatingSystem millisecondTime:(13/3) isAfter:16r0FFFFFFF   
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7230
     OperatingSystem millisecondTime:999 isAfter:16r0FFFFFFF       
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7231
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7232
     OperatingSystem millisecondTime:0 isAfter:0          
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7233
     OperatingSystem millisecondTime:(13/3) isAfter:0  
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7234
     OperatingSystem millisecondTime:999 isAfter:0       
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7235
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7236
     OperatingSystem millisecondTime:1 isAfter:0        
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7237
     OperatingSystem millisecondTime:(13/3) isAfter:2
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7238
     OperatingSystem millisecondTime:999 isAfter:900       
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7239
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7240
     |t1 t2|
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7241
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7242
     t1 := Time millisecondClockValue.
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7243
     (Delay forMilliseconds:1) wait.   
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7244
     t2 := Time millisecondClockValue.
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7245
     OperatingSystem millisecondTimeDeltaBetween:t2 and:t1 
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7246
    "
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7247
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7248
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7249
sleep:numberOfSeconds
1845
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7250
    "{ Pragma: +optSpace }"
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7251
308
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7252
    "cease ANY action for some time. This suspends the whole smalltalk
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7253
     (unix-) process for some time.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7254
     Not really useful since not even low-prio processes and interrupt
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7255
     handling will run during the sleep.
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7256
     Use either OperatingSystem>>millisecondDelay: (which makes all
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7257
     threads sleep, but handles interrupts) or use a Delay (which makes
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7258
     only the calling thread sleep)."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7259
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7260
%{  /* NOCONTEXT */
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7261
252
  7262
    if (__isSmallInteger(numberOfSeconds)) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  7263
	sleep(__intVal(numberOfSeconds));
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7264
	RETURN ( self );
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7265
    }
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  7266
%}.
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  7267
    "
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  7268
     argument not integer
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  7269
    "
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  7270
    ^ self primitiveFailed
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7271
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7272
    "
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7273
     OperatingSystem sleep:2
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7274
    "
10
claus
parents: 5
diff changeset
  7275
! !
claus
parents: 5
diff changeset
  7276
1799
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  7277
!OperatingSystem class methodsFor:'users & groups'!
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7278
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7279
getEffectiveGroupID
1845
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7280
    "{ Pragma: +optSpace }"
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7281
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7282
    "return the current users (thats you) effective numeric group id.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7283
     This is only different from getGroupID, if you have ST/X running
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7284
     as a setuid program (of which you should think about twice)."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7285
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7286
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7287
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7288
#ifdef UNIX_LIKE
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7289
    int uid;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7290
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7291
    uid = getegid();
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7292
    RETURN ( __MKSMALLINT(uid) );
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7293
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7294
    /* --- return same as getGroupID --- */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7295
%}.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7296
    ^ self getGroupID
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7297
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7298
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7299
     OperatingSystem getEffectiveGroupID
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7300
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7301
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7302
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7303
getEffectiveUserID
1845
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7304
    "{ Pragma: +optSpace }"
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7305
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7306
    "return the current users (thats you) effective numeric user id.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7307
     This is only different from getUserID, if you have ST/X running
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7308
     as a setuid program (of which you should think about twice)."
10
claus
parents: 5
diff changeset
  7309
claus
parents: 5
diff changeset
  7310
%{  /* NOCONTEXT */
claus
parents: 5
diff changeset
  7311
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7312
#ifdef UNIX_LIKE
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7313
    int uid;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7314
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7315
    uid = geteuid();
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7316
    RETURN ( __MKSMALLINT(uid) );
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7317
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7318
    /* --- return same as getUserID --- */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7319
%}.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7320
    ^ self getUserID
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7321
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7322
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7323
     OperatingSystem getEffectiveUserID
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7324
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7325
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7326
1549
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7327
getFullUserNameFromID:userID
1845
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7328
    "{ Pragma: +optSpace }"
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7329
1549
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7330
    "return a string with the users full name - if available.
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7331
     If not, return the login name as a fallBack."
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7332
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7333
    |info gecos|
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7334
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7335
    info := self userInfoOf:userID.
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7336
    (info notNil
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7337
    and:[info includesKey:#gecos]) ifTrue:[
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7338
	gecos := info at:#gecos.
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7339
	(gecos includes:$,) ifTrue:[
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7340
	    ^ gecos copyTo:(gecos indexOf:$,) - 1
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7341
	].
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7342
	^ gecos
1549
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7343
    ].
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7344
    ^ self getUserNameFromID:userID
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7345
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7346
    "
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7347
     OperatingSystem getFullUserNameFromID:0 
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7348
     OperatingSystem getFullUserNameFromID:(OperatingSystem getUserID)  
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7349
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7350
     OperatingSystem getUserNameFromID:(OperatingSystem getUserID)  
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7351
    "
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7352
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7353
    "Modified: 15.7.1996 / 12:44:21 / cg"
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7354
!
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7355
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7356
getGroupID
1845
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7357
    "{ Pragma: +optSpace }"
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7358
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7359
    "return the current users (thats you) numeric group id"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7360
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7361
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7362
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7363
#ifdef UNIX_LIKE
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7364
    int uid;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7365
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7366
    uid = getgid();
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7367
    RETURN ( __MKSMALLINT(uid) );
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7368
#else
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7369
# ifdef SYSTEM_HAS_GROUPS
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7370
    /* ... */
10
claus
parents: 5
diff changeset
  7371
# endif
claus
parents: 5
diff changeset
  7372
#endif
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  7373
%}.
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7374
    ^ 1 "just a dummy for systems which do not have userIDs"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7375
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  7376
    "
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7377
     OperatingSystem getGroupID
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7378
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7379
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7380
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7381
getGroupNameFromID:aNumber
1845
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7382
    "{ Pragma: +optSpace }"
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7383
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7384
    "return the group-name-string for a given numeric group-id"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7385
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7386
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7387
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7388
#ifdef UNIX_LIKE
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7389
    struct group *g;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7390
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7391
    if (__isSmallInteger(aNumber)) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  7392
	g = getgrgid(__intVal(aNumber));
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7393
	if (g) {
1688
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  7394
	    RETURN ( __MKSTRING(g->gr_name) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7395
	}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7396
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7397
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7398
%}.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7399
    ^ '???'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7400
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7401
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7402
     OperatingSystem getGroupNameFromID:0
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7403
     OperatingSystem getGroupNameFromID:10
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7404
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7405
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7406
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7407
getHomeDirectory
1845
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7408
    "{ Pragma: +optSpace }"
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7409
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7410
    "return the name of the users home directory"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7411
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7412
    ^ OperatingSystem getEnvironment:'HOME'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7413
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7414
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7415
     OperatingSystem getHomeDirectory
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7416
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7417
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7418
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7419
getLoginName
1845
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7420
    "{ Pragma: +optSpace }"
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7421
1549
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7422
    "return a string with the users login name"
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7423
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7424
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7425
    static char cachedName[64];
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7426
    static firstCall = 1;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7427
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7428
    char *name = (char *)0;
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7429
#ifdef UNIX_LIKE
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7430
    if (firstCall) {
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7431
	name = (char *)getlogin();
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7432
	if (! name || (name[0] == 0)) {
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7433
	    name = (char *)getenv("LOGNAME");
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7434
	}
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7435
	if (name && (strlen(name) < sizeof(cachedName))) {
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7436
	    strcpy(cachedName, name);
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7437
	    firstCall = 0;
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7438
	}
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7439
    } else {
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7440
	name = cachedName;
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7441
    }
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7442
#else
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  7443
# ifdef WIN32
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7444
    if (firstCall) {
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7445
	int nameSize = sizeof(cachedName);
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7446
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7447
	if (GetUserName(cachedName, &nameSize) == TRUE) {
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7448
	    name = cachedName;
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7449
	    firstCall = 0;
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7450
	}
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7451
    } else {
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7452
	name = cachedName;
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7453
    }
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7454
# endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7455
#endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7456
    if (! name || (name[0] == 0) ) {
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7457
	name = (char *)getenv("LOGNAME");
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7458
    }
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7459
    if (! name || (name[0] == 0) ) {
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7460
	name = "you";
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7461
    }
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7462
1688
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  7463
    RETURN ( __MKSTRING(name) );
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7464
%}.
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7465
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7466
     OperatingSystem getLoginName
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7467
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7468
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7469
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7470
getUserID
1845
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7471
    "{ Pragma: +optSpace }"
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7472
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7473
    "return the current users (thats you) numeric user id"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7474
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7475
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7476
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7477
#ifdef UNIX_LIKE
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7478
    int uid;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7479
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7480
    uid = getuid();
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7481
    RETURN ( __MKSMALLINT(uid) );
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7482
#else
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7483
# ifdef SYSTEM_HAS_USERS
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7484
    /* ... */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7485
# endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7486
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7487
%}.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7488
    ^ 1 "just a dummy for systems which do not have userIDs"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7489
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7490
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7491
     OperatingSystem getUserID
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  7492
    "
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7493
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7494
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7495
getUserNameFromID:aNumber
1845
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7496
    "{ Pragma: +optSpace }"
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7497
1549
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7498
    "return the user-name-string for a given numeric user-id.
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7499
     This is the login name, not the fullName."
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7500
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7501
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7502
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7503
#ifdef UNIX_LIKE
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7504
    struct passwd *p;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7505
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7506
    if (__isSmallInteger(aNumber)) {
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7507
	p = getpwuid(__intVal(aNumber));
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7508
	if (p) {
1688
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  7509
	    RETURN ( __MKSTRING(p->pw_name) );
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7510
	}
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7511
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7512
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7513
%}.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7514
    ^ '? (' , aNumber printString , ')'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7515
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7516
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7517
     OperatingSystem getUserNameFromID:0
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7518
     OperatingSystem getUserNameFromID:100
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7519
     OperatingSystem getUserNameFromID:9991 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7520
    "
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7521
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7522
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7523
userInfoOf:aNameOrID
1845
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7524
    "{ Pragma: +optSpace }"
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7525
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7526
    "return a dictionary filled with userinfo. The argument can be either
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7527
     a string with the users name or its numeric id.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7528
     Notice, that not all systems provide (all of) this info;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7529
     DOS systems return nothing; 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7530
     non-SYSV4 systems have no age/comment.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7531
     Portable applications may want to check the systemType and NOT depend
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7532
     on all keys to be present in the returned dictionary.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7533
     Another notice: on some systems (SYSV4), the gecos field includes multiple
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7534
     entries (i.e. not just the name), separated by commas. You may want to
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7535
     extract any substring, up to the first comma to get the real life name."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7536
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7537
    |info name passw uid gid age comment
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7538
     gecos dir shell|
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7539
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7540
%{
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7541
#ifdef UNIX_LIKE
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7542
    struct passwd *buf;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7543
    int ret;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7544
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7545
    if (__isString(aNameOrID)) {
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7546
	buf = getpwnam(__stringVal(aNameOrID));
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7547
    } else if (__isSmallInteger(aNameOrID)) {
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7548
	buf = getpwuid(__intVal(aNameOrID));
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7549
    } else {
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7550
	buf = (struct passwd *)0;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7551
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7552
    if (buf) {
1688
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  7553
	name = __MKSTRING(buf->pw_name);
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  7554
	passw = __MKSTRING(buf->pw_passwd);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7555
# ifdef SYSV4
1688
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  7556
	age = __MKSTRING(buf->pw_age);
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  7557
	comment = __MKSTRING(buf->pw_comment);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7558
# endif
1688
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  7559
	dir = __MKSTRING(buf->pw_dir);
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  7560
	gecos = __MKSTRING(buf->pw_gecos);
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  7561
	shell = __MKSTRING(buf->pw_shell);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7562
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  7563
	uid = __MKSMALLINT(buf->pw_uid);
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  7564
	gid = __MKSMALLINT(buf->pw_gid);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7565
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7566
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7567
%}.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7568
    info := IdentityDictionary new.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7569
    name notNil ifTrue:[
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7570
	info at:#name put:name.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7571
    ] ifFalse:[
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7572
	info at:#name put:'unknown'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7573
    ].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7574
    passw notNil ifTrue:[info at:#passwd put:passw].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7575
    age notNil ifTrue:[info at:#age put:age].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7576
    comment notNil ifTrue:[info at:#comment put:comment].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7577
    gecos notNil ifTrue:[info at:#gecos put:gecos].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7578
    shell notNil ifTrue:[info at:#shell put:shell].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7579
    dir notNil ifTrue:[info at:#dir put:dir].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7580
    uid notNil ifTrue:[info at:#uid put:uid].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7581
    gid  notNil ifTrue:[info at:#gid put:gid].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7582
    ^ info
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7583
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7584
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7585
     OperatingSystem userInfoOf:'root'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7586
     OperatingSystem userInfoOf:1
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7587
     OperatingSystem userInfoOf:'claus' 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7588
     OperatingSystem userInfoOf:'fooBar' 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7589
     OperatingSystem userInfoOf:(OperatingSystem getUserID)
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7590
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7591
! !
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7592
1799
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  7593
!OperatingSystem class methodsFor:'waiting for events'!
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7594
840
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  7595
blockingChildProcessWait
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  7596
     "return true, if childProcessWait: blocks, if no childs are ready"
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7597
%{ /*NOCONTEXT*/
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7598
#if defined(HAS_WAITPID) || defined(HAS_WAIT3)
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7599
    RETURN(false);
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7600
#else
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7601
    RETURN(true);
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7602
#endif
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7603
%}
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7604
!
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7605
840
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  7606
childProcessWait:blocking
1845
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7607
    "{ Pragma: +optSpace }"
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7608
840
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  7609
    "get status changes from child processes.
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  7610
     Return an OSProcessStatus or nil, if no process has terminated.
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  7611
     If blocking is true, we wait until a process changed state, 
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  7612
     otherwise we return immediately."
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  7613
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7614
    |pid status code core|
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7615
%{
1597
f35cd92a7648 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
  7616
#ifdef UNIX_LIKE
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7617
    int p;
1653
51bd45bcc19d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1633
diff changeset
  7618
1597
f35cd92a7648 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
  7619
# if defined(HAS_WAITPID)
1653
51bd45bcc19d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1633
diff changeset
  7620
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7621
    int s;
1653
51bd45bcc19d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1633
diff changeset
  7622
#   define __WAIT     waitpid(-1, &s, blocking == true ? WUNTRACED : WNOHANG|WUNTRACED)
51bd45bcc19d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1633
diff changeset
  7623
1597
f35cd92a7648 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
  7624
# else
f35cd92a7648 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
  7625
#  if defined(HAS_WAIT3)
1653
51bd45bcc19d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1633
diff changeset
  7626
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7627
    union wait s;
1653
51bd45bcc19d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1633
diff changeset
  7628
#   define __WAIT      wait3(&s, blocking == true ? WUNTRACED : WNOHANG|WUNTRACED, 0)
51bd45bcc19d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1633
diff changeset
  7629
51bd45bcc19d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1633
diff changeset
  7630
#  else /* neithe waitpid, nor wait3; use wait, which is blocking */
51bd45bcc19d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1633
diff changeset
  7631
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7632
    int s;
1653
51bd45bcc19d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1633
diff changeset
  7633
#   define __WAIT      wait(&s)
51bd45bcc19d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1633
diff changeset
  7634
#   define __BLOCKING_WAIT__ 1
1597
f35cd92a7648 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
  7635
1654
4352c5837f37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1653
diff changeset
  7636
    if (blocking != true) {
4352c5837f37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1653
diff changeset
  7637
	/*
4352c5837f37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1653
diff changeset
  7638
	 * We do not support nonBlocking waits, so signal an error
4352c5837f37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1653
diff changeset
  7639
	 * Sorry about the goto, but with all these ifdefs ...
4352c5837f37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1653
diff changeset
  7640
	 */
4352c5837f37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1653
diff changeset
  7641
	goto done;
4352c5837f37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1653
diff changeset
  7642
    }
4352c5837f37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1653
diff changeset
  7643
#  endif /*!HAS_WAIT3*/
4352c5837f37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1653
diff changeset
  7644
# endif  /*!HAS_WAITPID*/
4352c5837f37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1653
diff changeset
  7645
2098
8790a0a6b214 WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
  7646
# if !defined(WIFEXITED)
8790a0a6b214 WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
  7647
#  define WIFEXITED(stat)      (((int)((stat)&0377))==0)
8790a0a6b214 WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
  7648
#  define WIFSIGNALED(stat)    (((int)((stat)&0377))>0&&((int)(((stat)>>8)&0377))==0)
8790a0a6b214 WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
  7649
#  define WIFSTOPPED(stat)     (((int)((stat)&0377))==0177&&((int)(((stat)>>8)&0377))!=0)
8790a0a6b214 WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
  7650
8790a0a6b214 WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
  7651
#  define WEXITSTATUS(stat)    ((int)(((stat)>>8)&0377))
8790a0a6b214 WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
  7652
#  define WTERMSIG(stat)       (((int)((stat)&0377))&0177)
8790a0a6b214 WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
  7653
#  define WSTOPSIG(stat)       ((int)(((stat)>>8)&0377))
8790a0a6b214 WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
  7654
# endif /*!WIFEXITED*/
8790a0a6b214 WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
  7655
8790a0a6b214 WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
  7656
# if !defined(WCOREDUMP)
8790a0a6b214 WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
  7657
#  define WCOREDUMP(stat)      ((int)(((stat)>>8)&0200))
8790a0a6b214 WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
  7658
# endif /*!WCOREDUMP*/
1597
f35cd92a7648 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
  7659
f35cd92a7648 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
  7660
# if __BLOCKING_WAIT__
1433
8b2eacaea59c Getdomainname for Unixware.
Stefan Vogel <sv@exept.de>
parents: 1422
diff changeset
  7661
    __BEGIN_INTERRUPTABLE__
1597
f35cd92a7648 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
  7662
# endif
1433
8b2eacaea59c Getdomainname for Unixware.
Stefan Vogel <sv@exept.de>
parents: 1422
diff changeset
  7663
840
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  7664
    do {
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  7665
	p = __WAIT;
840
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  7666
    } while (p == -1 && errno == EINTR);
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  7667
1597
f35cd92a7648 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
  7668
# if __BLOCKING_WAIT__
1433
8b2eacaea59c Getdomainname for Unixware.
Stefan Vogel <sv@exept.de>
parents: 1422
diff changeset
  7669
    __END_INTERRUPTABLE__
1654
4352c5837f37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1653
diff changeset
  7670
#   undef __BLOCKING_WAIT__
1597
f35cd92a7648 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
  7671
# endif
f35cd92a7648 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
  7672
f35cd92a7648 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
  7673
# undef __WAIT
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7674
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7675
    if (p == 0)
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  7676
	RETURN(nil)
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7677
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7678
    if (p == -1) {
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  7679
	if (errno == ECHILD)
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  7680
	    RETURN(nil);
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7681
    } else {
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  7682
	pid = __MKSMALLINT(p);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  7683
	if (WIFEXITED(s)) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  7684
	    status = @symbol(exit);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  7685
	    code = __MKSMALLINT(WEXITSTATUS(s));
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  7686
	    core = WCOREDUMP(s) ? true : false;
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  7687
	} else if (WIFSIGNALED(s)) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  7688
	    status = @symbol(signal);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  7689
	    code = __MKSMALLINT(WTERMSIG(s));
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  7690
	} else if (WIFSTOPPED(s)) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  7691
	    status = @symbol(stop);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  7692
	    code = __MKSMALLINT(WSTOPSIG(s));
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  7693
	}
1597
f35cd92a7648 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
  7694
# if defined(WIFCONTINUED)
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  7695
	else if (WIFCONTINUED(s)) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  7696
	    status = @symbol(continue);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  7697
	} 
1597
f35cd92a7648 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
  7698
# endif
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7699
    }
840
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  7700
done: ;
1597
f35cd92a7648 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
  7701
#endif /* UNIX_LIKE */
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7702
%}.
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7703
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7704
    pid isNil ifTrue:[
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  7705
	^ self primitiveFailed
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7706
    ].
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7707
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7708
    ^ OSProcessStatus pid:pid status:status code:code core:core
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7709
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7710
    "
840
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  7711
     OperatingSystem childProcessWait:false
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7712
    "
840
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  7713
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  7714
    "Created: 5.1.1996 / 16:39:14 / stefan"
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7715
!
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7716
10
claus
parents: 5
diff changeset
  7717
readCheck:fd
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7718
    "return true, if data is available on a filedescriptor (i.e. read
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7719
     is possible without blocking)"
10
claus
parents: 5
diff changeset
  7720
claus
parents: 5
diff changeset
  7721
    (self selectOnAnyReadable:(Array with:fd)
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7722
		     writable:nil
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7723
		    exception:nil
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7724
		  withTimeOut:0) == fd
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7725
	ifTrue:[^ true].
10
claus
parents: 5
diff changeset
  7726
    ^ false
claus
parents: 5
diff changeset
  7727
!
claus
parents: 5
diff changeset
  7728
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7729
selectOn:fd1 and:fd2 withTimeOut:millis
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7730
    "wait for any fd to become ready; timeout after t milliseconds.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7731
     A zero timeout-time will immediately return (i.e. poll).
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7732
     Return fd if i/o ok, nil if timed-out or interrupted.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7733
     Obsolete:
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7734
	This is a leftover method and will vanish."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7735
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7736
    ^ self selectOnAnyReadable:(Array with:fd1 with:fd2)
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7737
		      writable:(Array with:fd1 with:fd2)
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7738
		     exception:nil
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7739
		   withTimeOut:millis
10
claus
parents: 5
diff changeset
  7740
!
claus
parents: 5
diff changeset
  7741
claus
parents: 5
diff changeset
  7742
selectOn:fd withTimeOut:millis
claus
parents: 5
diff changeset
  7743
    "wait for aFileDesriptor to become ready; timeout after t milliseconds.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7744
     Return true, if i/o ok, false if timed-out or interrupted.
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7745
     With 0 as timeout argument, this can be used to check for availability
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7746
     of read-data.
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7747
     Experimental."
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7748
3
24d81bf47225 *** empty log message ***
claus
parents: 2
diff changeset
  7749
    ^ self selectOnAnyReadable:(Array with:fd)
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7750
		      writable:(Array with:fd)
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7751
		     exception:nil
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7752
		   withTimeOut:millis
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7753
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7754
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7755
selectOnAny:fdArray withTimeOut:millis
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7756
    "wait for any fd in fdArray (an Array of integers) to become ready;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7757
     timeout after t milliseconds. An empty set will always wait.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7758
     Return first ready fd if i/o ok, nil if timed-out or interrupted.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7759
     Experimental."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7760
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7761
    ^ self selectOnAnyReadable:fdArray
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7762
		      writable:fdArray
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7763
		     exception:nil
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7764
		   withTimeOut:millis
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7765
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7766
10
claus
parents: 5
diff changeset
  7767
selectOnAnyReadable:fdArray withTimeOut:millis
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7768
    "wait for any fd in fdArray (an Array of integers) to become ready for 
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7769
     reading. Timeout after t milliseconds. An empty set will always wait.
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7770
     A zero timeout-time will immediately return (i.e. poll).
3
24d81bf47225 *** empty log message ***
claus
parents: 2
diff changeset
  7771
     Return first ready fd if i/o ok, nil if timed-out or interrupted.
24d81bf47225 *** empty log message ***
claus
parents: 2
diff changeset
  7772
     Experimental."
24d81bf47225 *** empty log message ***
claus
parents: 2
diff changeset
  7773
24d81bf47225 *** empty log message ***
claus
parents: 2
diff changeset
  7774
    ^ self selectOnAnyReadable:fdArray 
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7775
		      writable:nil 
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7776
		     exception:nil
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7777
		   withTimeOut:millis
3
24d81bf47225 *** empty log message ***
claus
parents: 2
diff changeset
  7778
!
24d81bf47225 *** empty log message ***
claus
parents: 2
diff changeset
  7779
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7780
selectOnAnyReadable:readFdArray writable:writeFdArray exception:exceptFdArray withTimeOut:millis
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7781
    "wait for any fd in readFdArray (an Array of integers) to become ready for 
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7782
     reading, writeFdArray to become ready for writing, or exceptFdArray to 
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7783
     arrive exceptional data (i.e. out-of-band data).
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7784
     Timeout after t milliseconds or, if the timeout time is 0, immediately..
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7785
     Empty fd-sets will always wait. Zero time can be used to poll file-
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7786
     descriptors (i.e. to check if I/O possible without blocking).
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7787
     Return first ready fd if I/O ok, nil if timed-out or interrupted."
3
24d81bf47225 *** empty log message ***
claus
parents: 2
diff changeset
  7788
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7789
%{
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7790
#ifdef MSDOS_LIKE
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7791
    /*
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7792
     * support a delay-wait only
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7793
     * (i.e. fail if any filedescriptor is selected upon)
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7794
     */
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7795
    int count;
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7796
    int i;
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7797
    int t;
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7798
    OBJ fd;
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7799
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7800
    if (! __isSmallInteger(millis)) {
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7801
	goto fail;
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7802
    }
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7803
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7804
    if (readFdArray != nil) {
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  7805
	if (! __isArray(readFdArray)) {
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  7806
	    goto fail;  
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7807
	}
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7808
	count = __arraySize(readFdArray);
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7809
	for (i=0; i<count;i++) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  7810
	    fd = __ArrayInstPtr(readFdArray)->a_element[i];
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7811
	    if (fd != nil) {
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7812
		goto fail;
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7813
	    }
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7814
	}
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7815
    }
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7816
    if (writeFdArray != nil) {
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7817
	if (! __isArray(writeFdArray)) {
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7818
	    goto fail;
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7819
	}
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7820
	count = __arraySize(writeFdArray);
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7821
	for (i=0; i<count;i++) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  7822
	    fd = __ArrayInstPtr(writeFdArray)->a_element[i];
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7823
	    if (fd != nil) {
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7824
		goto fail;
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7825
	    }
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7826
	}
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7827
    }
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7828
    if (exceptFdArray != nil) {
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7829
	if (! __isArray(exceptFdArray)) {
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7830
	    goto fail;
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7831
	}
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7832
	count = __arraySize(exceptFdArray);
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7833
	for (i=0; i<count;i++) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  7834
	    fd = __ArrayInstPtr(exceptFdArray)->a_element[i];
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7835
	    if (fd != nil) {
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7836
		goto fail;
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7837
	    }
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7838
	}
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7839
    }
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  7840
    t = __intVal(millis);
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7841
    if (t != 0) {
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  7842
	/*
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  7843
	 * delay only 
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  7844
	 */
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7845
	Sleep(t);
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7846
    }
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7847
    RETURN (nil);
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7848
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7849
#else /* not MSDOS_LIKE */
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7850
    fd_set rset, wset, eset;
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7851
    struct timeval wt, et;
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7852
    int t, f, maxF, i, lX, bX;
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7853
    OBJ fd, retFd;
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7854
    int ret;
300
fe1f742a9224 *** empty log message ***
claus
parents: 275
diff changeset
  7855
    int count;
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7856
252
  7857
    if (__isSmallInteger(millis)) {
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7858
	FD_ZERO(&rset);
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7859
	FD_ZERO(&wset);
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7860
	FD_ZERO(&eset);
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7861
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7862
	maxF = -1;
308
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7863
	if (readFdArray != nil) {
300
fe1f742a9224 *** empty log message ***
claus
parents: 275
diff changeset
  7864
	    if (! __isArray(readFdArray)) {
fe1f742a9224 *** empty log message ***
claus
parents: 275
diff changeset
  7865
		goto fail;    
fe1f742a9224 *** empty log message ***
claus
parents: 275
diff changeset
  7866
	    }
fe1f742a9224 *** empty log message ***
claus
parents: 275
diff changeset
  7867
	    count = __arraySize(readFdArray);
308
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7868
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7869
	    for (i=0; i<count;i++) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  7870
		fd = __ArrayInstPtr(readFdArray)->a_element[i];
308
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7871
		if (fd != nil) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  7872
		    f = __intVal(fd);
308
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7873
		    if ((f >= 0) && (f < FD_SETSIZE)) {
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7874
			FD_SET(f, &rset);
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7875
			if (f > maxF) maxF = f;
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7876
		    }
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7877
		}
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7878
	    }
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7879
	}
300
fe1f742a9224 *** empty log message ***
claus
parents: 275
diff changeset
  7880
308
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7881
	if (writeFdArray != nil) {
300
fe1f742a9224 *** empty log message ***
claus
parents: 275
diff changeset
  7882
	    if (! __isArray(writeFdArray)) {
fe1f742a9224 *** empty log message ***
claus
parents: 275
diff changeset
  7883
		goto fail;    
fe1f742a9224 *** empty log message ***
claus
parents: 275
diff changeset
  7884
	    }
fe1f742a9224 *** empty log message ***
claus
parents: 275
diff changeset
  7885
	    count = __arraySize(writeFdArray);
308
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7886
	    for (i=0; i<count;i++) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  7887
		fd = __ArrayInstPtr(writeFdArray)->a_element[i];
308
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7888
		if (fd != nil) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  7889
		    f = __intVal(fd);
308
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7890
		    if ((f >= 0) && (f < FD_SETSIZE)) {
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7891
			FD_SET(f, &wset);       
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7892
			if (f > maxF) maxF = f;
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7893
		    }
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7894
		}
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7895
	    }
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7896
	}
300
fe1f742a9224 *** empty log message ***
claus
parents: 275
diff changeset
  7897
308
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7898
	if (exceptFdArray != nil) {
300
fe1f742a9224 *** empty log message ***
claus
parents: 275
diff changeset
  7899
	    if (! __isArray(exceptFdArray)) {
fe1f742a9224 *** empty log message ***
claus
parents: 275
diff changeset
  7900
		goto fail;    
fe1f742a9224 *** empty log message ***
claus
parents: 275
diff changeset
  7901
	    }
fe1f742a9224 *** empty log message ***
claus
parents: 275
diff changeset
  7902
	    count = __arraySize(exceptFdArray);
308
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7903
	    for (i=0; i<count;i++) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  7904
		fd = __ArrayInstPtr(exceptFdArray)->a_element[i];
308
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7905
		if (fd != nil) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  7906
		    f = __intVal(fd);
308
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7907
		    if ((f >= 0) && (f < FD_SETSIZE)) {
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7908
			FD_SET(f, &eset);       
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7909
			if (f > maxF) maxF = f;
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7910
		    }
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7911
		}
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7912
	    }
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7913
	}
308
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7914
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  7915
	t = __intVal(millis);
774
e0ee05157570 selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  7916
	if (t) {
e0ee05157570 selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  7917
	    wt.tv_sec = t / 1000;
e0ee05157570 selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  7918
	    wt.tv_usec = (t % 1000) * 1000;
e0ee05157570 selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  7919
	} else {
e0ee05157570 selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  7920
	    wt.tv_sec = wt.tv_usec = 0;
e0ee05157570 selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  7921
	}
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7922
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7923
	/*
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7924
	 * make certain, that interrupt gets us out of the select
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7925
	 */
362
claus
parents: 359
diff changeset
  7926
	__BEGIN_INTERRUPTABLE__
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7927
	errno = 0;
774
e0ee05157570 selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  7928
e0ee05157570 selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  7929
	if (t == 0) {
e0ee05157570 selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  7930
	    /* 
e0ee05157570 selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  7931
	     * if there is no timeout time, we can stay here 
e0ee05157570 selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  7932
	     * interruptable.
e0ee05157570 selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  7933
	     */
e0ee05157570 selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  7934
	    do {
e0ee05157570 selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  7935
		ret = select(maxF+1, &rset, &wset, &eset, &wt);
e0ee05157570 selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  7936
	    } while ((ret < 0) && (errno == EINTR));
e0ee05157570 selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  7937
	} else {
e0ee05157570 selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  7938
	    do {
813
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  7939
		ret = select(maxF+1, &rset, &wset, &eset, &wt);
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  7940
		/* 
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  7941
		 * for now: dont loop; if we did, we had to adjust the vt-timeval;
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  7942
		 * could otherwise stay in this loop forever ...
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  7943
		 * Premature return (before the time expired) must be handled by the caller.
774
e0ee05157570 selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  7944
		 * A good solution is to update the wt-timeval and redo the select.
813
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  7945
		 */
774
e0ee05157570 selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  7946
	    } while (0 /* (ret < 0) && (errno == EINTR) */ );
e0ee05157570 selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  7947
	}
362
claus
parents: 359
diff changeset
  7948
	__END_INTERRUPTABLE__
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7949
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7950
	if (ret > 0) {
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7951
	    for (i=0; i <= maxF; i++) {
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7952
		if (FD_ISSET(i, &rset)
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7953
		 || FD_ISSET(i, &wset)
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7954
		 || FD_ISSET(i, &eset)) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  7955
		    RETURN ( __MKSMALLINT(i) );
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7956
		}
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7957
	    }
855
2de3c842c687 dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  7958
	} else {
2de3c842c687 dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  7959
	    if (ret < 0) {
2de3c842c687 dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  7960
		if (errno != EINTR) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  7961
		    fprintf(stderr, "OS: select errno = %d\n", errno);
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  7962
		    OperatingSystem_LastErrorNumber = __MKSMALLINT(errno);
855
2de3c842c687 dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  7963
		}
2de3c842c687 dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  7964
	    }
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7965
	}
308
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7966
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7967
	/*
2117
460b14a6db96 added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
  7968
	 * return nil (means time expired or interrupted)
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7969
	 */
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7970
	RETURN ( nil );
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7971
    }
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7972
#endif /* not MSDOS_LIKE */
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7973
300
fe1f742a9224 *** empty log message ***
claus
parents: 275
diff changeset
  7974
fail: ;
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  7975
%}.
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  7976
    "
300
fe1f742a9224 *** empty log message ***
claus
parents: 275
diff changeset
  7977
     timeout argument not integer,
fe1f742a9224 *** empty log message ***
claus
parents: 275
diff changeset
  7978
     or any fd-array nonNil and not an array
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  7979
     or not supported by OS
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  7980
    "
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  7981
    ^ self primitiveFailed
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7982
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7983
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7984
setBlocking:aBoolean on:fd
1845
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7985
    "{ Pragma: +optSpace }"
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7986
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7987
    "set/clear the blocking attribute - if set (which is the default)
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7988
     a read on the fileDescriptor will block until data is available.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7989
     If cleared, a read operation will immediately return with a value of
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7990
     nil."
10
claus
parents: 5
diff changeset
  7991
claus
parents: 5
diff changeset
  7992
%{  /* NOCONTEXT */
claus
parents: 5
diff changeset
  7993
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7994
    int ret, flags;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7995
    int savInt;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7996
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7997
#if defined(F_GETFL) && defined(F_SETFL)
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7998
# if defined(FNDELAY)
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7999
    if (__isSmallInteger(fd)) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  8000
	int f = __intVal(fd);
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  8001
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  8002
	flags = fcntl(f, F_GETFL, 0);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  8003
	if (aBoolean == true) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  8004
	    ret = fcntl(f, F_SETFL, flags & ~FNDELAY);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  8005
	} else {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  8006
	    ret = fcntl(f, F_SETFL, flags | FNDELAY);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  8007
	}
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  8008
	if (ret >= 0) ret = flags;
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  8009
	RETURN ( __MKSMALLINT(ret) );
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  8010
    }
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  8011
# endif
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  8012
#endif
308
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  8013
%}.
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  8014
    "
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  8015
     fd argument not integer
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  8016
    "
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  8017
    ^ self primitiveFailed
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  8018
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  8019
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  8020
writeCheck:fd
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  8021
    "return true, if filedescriptor can be written without blocking"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  8022
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  8023
    (self selectOnAnyReadable:nil
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  8024
		     writable:(Array with:fd)
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  8025
		    exception:nil
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  8026
		  withTimeOut:0) == fd
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  8027
	ifTrue:[^ true].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  8028
    ^ false
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  8029
! !
434
0511ecb7c818 *** empty log message ***
claus
parents: 433
diff changeset
  8030
1966
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8031
!OperatingSystem::OSProcessStatus class methodsFor:'documentation'!
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8032
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8033
documentation
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8034
"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8035
    This is an auxillary class, that holds information about status changes of
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8036
    operating system processes (these are no smalltalk processes!!).
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8037
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8038
    [Instance variables:]
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8039
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8040
	pid     <Integer>       OS-Process identifier
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8041
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8042
	status  <Symbol>        either #exit #signal #stop #continue
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8043
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8044
	code    <Integer>       either exitcode or signalnumber
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8045
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8046
	core    <Boolean>       true if core has been dumped
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8047
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8048
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8049
    [author:]
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8050
	Stefan Vogel
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8051
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8052
    [see also:]
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8053
	OperatingSystem
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8054
"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8055
! !
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8056
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8057
!OperatingSystem::OSProcessStatus class methodsFor:'instance creation'!
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8058
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8059
pid:pid status:status code:code core:core
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8060
    "private interface for OperatingSystem"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8061
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8062
    ^ self new pid:pid status:status code:code core:core
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8063
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8064
    "Created: 28.12.1995 / 14:16:14 / stefan"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8065
    "Modified: 30.4.1996 / 18:25:00 / cg"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8066
!
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8067
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8068
processCreationFailure
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8069
    "private interface for OperatingSystem"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8070
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8071
    ^ self new pid:-1 status:#failure code:-1 core:false
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8072
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8073
    "Created: 28.12.1995 / 14:35:29 / stefan"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8074
    "Modified: 30.4.1996 / 18:25:05 / cg"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8075
! !
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8076
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8077
!OperatingSystem::OSProcessStatus methodsFor:'accessing'!
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8078
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8079
code
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8080
    "return the exitcode / signalNumber"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8081
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8082
    ^ code
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8083
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8084
    "Created: 28.12.1995 / 14:05:07 / stefan"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8085
    "Modified: 30.4.1996 / 18:26:23 / cg"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8086
!
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8087
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8088
core
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8089
    "return true if core has been dumped, false otherwise"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8090
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8091
    ^ core == true
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8092
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8093
    "Modified: 28.12.1995 / 14:14:38 / stefan"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8094
!
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8095
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8096
pid
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8097
    "return the pid"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8098
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8099
    ^ pid
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8100
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8101
    "Created: 28.12.1995 / 14:05:07 / stefan"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8102
    "Modified: 30.4.1996 / 18:26:30 / cg"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8103
!
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8104
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8105
status
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8106
    "return status as a Symbol;
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8107
     one of #exit #signal #stop #continue"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8108
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8109
    ^ status
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8110
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8111
    "Created: 28.12.1995 / 14:05:07 / stefan"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8112
    "Modified: 30.4.1996 / 18:26:54 / cg"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8113
! !
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8114
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8115
!OperatingSystem::OSProcessStatus methodsFor:'initialization'!
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8116
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8117
pid:newPid status:newStatus code:newCode core:newCore
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8118
    pid := newPid.
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8119
    status := newStatus.
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8120
    code := newCode.
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8121
    core := newCore.
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8122
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8123
    "Created: 28.12.1995 / 14:18:22 / stefan"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8124
! !
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8125
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8126
!OperatingSystem::OSProcessStatus methodsFor:'private-OS interface'!
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8127
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8128
code:something
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8129
    "set the exitCode"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8130
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8131
    code := something.
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8132
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8133
    "Created: 28.12.1995 / 14:05:07 / stefan"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8134
    "Modified: 30.4.1996 / 18:25:18 / cg"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8135
!
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8136
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8137
core:something
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8138
    "set core"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8139
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8140
    core := something.
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8141
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8142
    "Created: 28.12.1995 / 14:05:07 / stefan"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8143
!
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8144
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8145
pid:something
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8146
    "set pid"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8147
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8148
    pid := something.
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8149
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8150
    "Created: 28.12.1995 / 14:05:07 / stefan"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8151
!
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8152
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8153
status:something
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8154
    "set status"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8155
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8156
    status := something.
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8157
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8158
    "Created: 28.12.1995 / 14:05:07 / stefan"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8159
! !
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8160
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8161
!OperatingSystem::OSProcessStatus methodsFor:'queries'!
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8162
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8163
couldNotExecute
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8164
    "return true when a command could not be executed"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8165
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8166
    ^ status == #exit and:[code = 127].
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8167
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8168
    "Created: 28.12.1995 / 15:43:17 / stefan"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8169
    "Modified: 30.4.1996 / 18:27:03 / cg"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8170
!
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8171
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8172
stillAlive
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8173
    "true if process is still alive"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8174
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8175
    ^ status == #stop or:[status == #continue]
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8176
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8177
    "Created: 28.12.1995 / 14:27:26 / stefan"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8178
!
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8179
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8180
success
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8181
    "true if process terminated successfully"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8182
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8183
    ^ status == #exit and:[code = 0]
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8184
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8185
    "Created: 28.12.1995 / 14:13:05 / stefan"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8186
    "Modified: 28.12.1995 / 14:13:41 / stefan"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8187
! !
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8188
2080
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8189
!OperatingSystem::FileStatusInfo class methodsFor:'instance creation'!
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8190
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8191
type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT statusChanged:sT path:lP
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8192
    ^ self basicNew
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8193
	type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT statusChanged:sT path:lP       
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8194
! !
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8195
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8196
!OperatingSystem::FileStatusInfo methodsFor:'accessing'!
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8197
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8198
accessed
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8199
    "return accessed"
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8200
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8201
    ^ accessed!
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8202
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8203
gid
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8204
    "return gid"
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8205
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8206
    ^ gid!
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8207
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8208
id
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8209
    "return id"
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8210
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8211
    ^ id!
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8212
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8213
mode
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8214
    "return mode"
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8215
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8216
    ^ mode!
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8217
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8218
modified
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8219
    "return modified"
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8220
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8221
    ^ modified!
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8222
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8223
path
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8224
    "for symbolic links only: return the path where the symbolic link points to"
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8225
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8226
    ^ path
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8227
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8228
!
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8229
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8230
size
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8231
    "return size"
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8232
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8233
    ^ size!
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8234
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8235
statusChanged
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8236
    "return statusChanged"
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8237
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8238
    ^ statusChanged!
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8239
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8240
type
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8241
    "return type"
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8242
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8243
    ^ type!
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8244
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8245
uid
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8246
    "return uid"
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8247
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8248
    ^ uid! !
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8249
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8250
!OperatingSystem::FileStatusInfo methodsFor:'backward compatibility'!
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8251
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8252
at:key
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8253
    "backward compatibility access: in previous releases, IdentityDictionaries
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8254
     were used to hold my information. Allow access via key messages.
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8255
     This method will vanish - use the proper access protocol."
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8256
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8257
    ^ self perform:key
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8258
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8259
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8260
! !
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8261
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8262
!OperatingSystem::FileStatusInfo methodsFor:'private accessing'!
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8263
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8264
type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT statusChanged:sT path:lP
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8265
    type := t.
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8266
    mode := m.
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8267
    uid := u.
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8268
    gid := g.
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8269
    size := s.
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8270
    id := i.
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8271
    accessed := aT.
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8272
    modified := mT.
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8273
    statusChanged := sT.
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8274
    path := lP
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8275
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8276
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8277
! !
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8278
1799
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  8279
!OperatingSystem class methodsFor:'documentation'!
630
b785d23d7c5b version at the end
Claus Gittinger <cg@exept.de>
parents: 616
diff changeset
  8280
b785d23d7c5b version at the end
Claus Gittinger <cg@exept.de>
parents: 616
diff changeset
  8281
version
2117
460b14a6db96 added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
  8282
    ^ '$Header: /cvs/stx/stx/libbasic/Attic/Unix.st,v 1.187 1997-01-10 11:20:24 cg Exp $'
630
b785d23d7c5b version at the end
Claus Gittinger <cg@exept.de>
parents: 616
diff changeset
  8283
! !
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  8284
OperatingSystem initialize!