Mercurial > hg > xemacs-beta
comparison src/sysdep.c @ 2:ac2d302a0011 r19-15b2
Import from CVS: tag r19-15b2
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:46:35 +0200 |
parents | 376386a54a3c |
children | bcdc7deadc19 |
comparison
equal
deleted
inserted
replaced
1:c0c6a60d29db | 2:ac2d302a0011 |
---|---|
49 #include "process.h" | 49 #include "process.h" |
50 #include "sysdep.h" | 50 #include "sysdep.h" |
51 #include "window.h" | 51 #include "window.h" |
52 | 52 |
53 #include <setjmp.h> | 53 #include <setjmp.h> |
54 #ifdef HAVE_LIBGEN_H /* Must come before sysfile.h */ | |
55 #include <libgen.h> | |
56 #endif | |
54 #include "sysfile.h" | 57 #include "sysfile.h" |
55 #include "syswait.h" | 58 #include "syswait.h" |
56 #include "sysdir.h" | 59 #include "sysdir.h" |
57 #include "systime.h" | 60 #include "systime.h" |
58 #include <sys/times.h> | 61 #include <sys/times.h> |
906 static void | 909 static void |
907 init_sigio_on_device (struct device *d) | 910 init_sigio_on_device (struct device *d) |
908 { | 911 { |
909 int filedesc = DEVICE_INFD (d); | 912 int filedesc = DEVICE_INFD (d); |
910 | 913 |
911 #if defined (I_SETSIG) | 914 #if defined (I_SETSIG) && !defined(HPUX10) |
912 ioctl (filedesc, I_GETSIG, &DEVICE_OLD_SIGIO_FLAG (d)); | 915 ioctl (filedesc, I_GETSIG, &DEVICE_OLD_SIGIO_FLAG (d)); |
913 DEVICE_OLD_SIGIO_FLAG (d) &= ~S_INPUT; | 916 DEVICE_OLD_SIGIO_FLAG (d) &= ~S_INPUT; |
914 #elif defined (FASYNC) | 917 #elif defined (FASYNC) |
915 DEVICE_OLD_SIGIO_FLAG (d) = | 918 DEVICE_OLD_SIGIO_FLAG (d) = |
916 fcntl (filedesc, F_GETFL, 0) & ~FASYNC; | 919 fcntl (filedesc, F_GETFL, 0) & ~FASYNC; |
927 ioctl_status = ioctl (filedesc, FIOSSAIOOWN, &owner); | 930 ioctl_status = ioctl (filedesc, FIOSSAIOOWN, &owner); |
928 } | 931 } |
929 #ifdef HAVE_WINDOW_SYSTEM | 932 #ifdef HAVE_WINDOW_SYSTEM |
930 else if (!DEVICE_STREAM_P (d)) | 933 else if (!DEVICE_STREAM_P (d)) |
931 { | 934 { |
932 /* Process group for socket should be -pid for delivery to self. */ | |
933 owner = -owner; | |
934 ioctl_status = ioctl (filedesc, SIOCGPGRP, | 935 ioctl_status = ioctl (filedesc, SIOCGPGRP, |
935 &DEVICE_OLD_FCNTL_OWNER (d)); | 936 &DEVICE_OLD_FCNTL_OWNER (d)); |
936 ioctl_status = ioctl (filedesc, SIOCSPGRP, &owner); | 937 ioctl_status = ioctl (filedesc, SIOCSPGRP, &owner); |
937 } | 938 } |
938 #endif | 939 #endif |
963 &DEVICE_OLD_FCNTL_OWNER (d)); | 964 &DEVICE_OLD_FCNTL_OWNER (d)); |
964 } | 965 } |
965 #ifdef HAVE_WINDOW_SYSTEM | 966 #ifdef HAVE_WINDOW_SYSTEM |
966 else if (!DEVICE_STREAM_P (d)) | 967 else if (!DEVICE_STREAM_P (d)) |
967 { | 968 { |
968 /* Process group for socket should be -pid for delivery to self. */ | |
969 owner = -owner; | |
970 ioctl_status = ioctl (filedesc, SIOCSPGRP, | 969 ioctl_status = ioctl (filedesc, SIOCSPGRP, |
971 &DEVICE_OLD_FCNTL_OWNER (d)); | 970 &DEVICE_OLD_FCNTL_OWNER (d)); |
972 } | 971 } |
973 #endif | 972 #endif |
974 } | 973 } |
985 /* prevent redundant ioctl()s, which may cause syslog messages | 984 /* prevent redundant ioctl()s, which may cause syslog messages |
986 (e.g. on Solaris) */ | 985 (e.g. on Solaris) */ |
987 if (d->sigio_enabled) | 986 if (d->sigio_enabled) |
988 return; | 987 return; |
989 | 988 |
990 #if defined (I_SETSIG) | 989 #if defined (I_SETSIG) && !defined(HPUX10) |
991 ioctl (filedesc, I_SETSIG, DEVICE_OLD_SIGIO_FLAG (d) | S_INPUT); | 990 ioctl (filedesc, I_SETSIG, DEVICE_OLD_SIGIO_FLAG (d) | S_INPUT); |
992 #elif defined (FASYNC) | 991 #elif defined (FASYNC) |
993 fcntl (filedesc, F_SETFL, DEVICE_OLD_SIGIO_FLAG (d) | FASYNC); | 992 fcntl (filedesc, F_SETFL, DEVICE_OLD_SIGIO_FLAG (d) | FASYNC); |
994 #elif defined (FIOSSAIOSTAT) | 993 #elif defined (FIOSSAIOSTAT) |
995 { | 994 { |
997 sockets and other devices for some bizarre reason. We guess | 996 sockets and other devices for some bizarre reason. We guess |
998 that an X device is a socket, and tty devices aren't. We then | 997 that an X device is a socket, and tty devices aren't. We then |
999 use the following crud to do the appropriate thing. */ | 998 use the following crud to do the appropriate thing. */ |
1000 int on = 1; | 999 int on = 1; |
1001 int ioctl_status; /* ####DG: check if IOCTL succeeds here. */ | 1000 int ioctl_status; /* ####DG: check if IOCTL succeeds here. */ |
1002 int socket_pgroup = -getpid (); | |
1003 | 1001 |
1004 if (DEVICE_TTY_P (d)) | 1002 if (DEVICE_TTY_P (d)) |
1005 { | 1003 { |
1006 ioctl_status = ioctl (filedesc, FIOSSAIOSTAT, &on); | 1004 ioctl_status = ioctl (filedesc, FIOSSAIOSTAT, &on); |
1007 } | 1005 } |
1008 #ifdef HAVE_WINDOW_SYSTEM | 1006 #ifdef HAVE_WINDOW_SYSTEM |
1009 else if (!DEVICE_STREAM_P (d)) | 1007 else if (!DEVICE_STREAM_P (d)) |
1010 { | 1008 { |
1011 ioctl_status = ioctl (filedesc, FIOASYNC, &on); | 1009 ioctl_status = ioctl (filedesc, FIOASYNC, &on); |
1012 ioctl_status = ioctl (filedesc, SIOCSPGRP, &socket_pgroup); | |
1013 } | 1010 } |
1014 #endif | 1011 #endif |
1015 } | 1012 } |
1016 #elif defined (FIOASYNC) | 1013 #elif defined (FIOASYNC) |
1017 { | 1014 { |
1035 /* prevent redundant ioctl()s, which may cause syslog messages | 1032 /* prevent redundant ioctl()s, which may cause syslog messages |
1036 (e.g. on Solaris) */ | 1033 (e.g. on Solaris) */ |
1037 if (!d->sigio_enabled) | 1034 if (!d->sigio_enabled) |
1038 return; | 1035 return; |
1039 | 1036 |
1040 #if defined (I_SETSIG) | 1037 #if defined (I_SETSIG) && !defined(HPUX10) |
1041 ioctl (filedesc, I_SETSIG, DEVICE_OLD_SIGIO_FLAG (d)); | 1038 ioctl (filedesc, I_SETSIG, DEVICE_OLD_SIGIO_FLAG (d)); |
1042 #elif defined (FASYNC) | 1039 #elif defined (FASYNC) |
1043 fcntl (filedesc, F_SETFL, DEVICE_OLD_SIGIO_FLAG (d)); | 1040 fcntl (filedesc, F_SETFL, DEVICE_OLD_SIGIO_FLAG (d)); |
1044 #elif defined (FIOSSAIOSTAT) | 1041 #elif defined (FIOSSAIOSTAT) |
1045 { | 1042 { |
1047 sockets and other devices for some bizarre reason. We guess | 1044 sockets and other devices for some bizarre reason. We guess |
1048 that an X device is a socket, and tty devices aren't. We then | 1045 that an X device is a socket, and tty devices aren't. We then |
1049 use the following crud to do the appropriate thing. */ | 1046 use the following crud to do the appropriate thing. */ |
1050 | 1047 |
1051 int off = 0; | 1048 int off = 0; |
1052 int socket_pgroup = 0; | |
1053 int ioctl_status; | 1049 int ioctl_status; |
1054 | 1050 |
1055 /* See comment for request_sigio_on_device */ | 1051 /* See comment for request_sigio_on_device */ |
1056 | 1052 |
1057 if (DEVICE_TTY_P (d)) | 1053 if (DEVICE_TTY_P (d)) |
1059 ioctl_status = ioctl (filedesc, FIOSSAIOSTAT, &off); | 1055 ioctl_status = ioctl (filedesc, FIOSSAIOSTAT, &off); |
1060 } | 1056 } |
1061 else | 1057 else |
1062 { | 1058 { |
1063 ioctl_status = ioctl (filedesc, FIOASYNC, &off); | 1059 ioctl_status = ioctl (filedesc, FIOASYNC, &off); |
1064 ioctl_status = ioctl (filedesc, SIOCSPGRP, &socket_pgroup); | |
1065 } | 1060 } |
1066 } | 1061 } |
1067 #elif defined (FIOASYNC) | 1062 #elif defined (FIOASYNC) |
1068 { | 1063 { |
1069 int off = 0; | 1064 int off = 0; |
3056 DIRENTRY * | 3051 DIRENTRY * |
3057 sys_readdir (DIR *dirp) | 3052 sys_readdir (DIR *dirp) |
3058 { | 3053 { |
3059 DIRENTRY *rtnval; | 3054 DIRENTRY *rtnval; |
3060 | 3055 |
3061 /* #### currently we don't do conversions on the incoming data */ | |
3062 /* Apparently setting errno is necessary on some systems? | 3056 /* Apparently setting errno is necessary on some systems? |
3063 Maybe readdir() doesn't always set errno ?! */ | 3057 Maybe readdir() doesn't always set errno ?! */ |
3064 while (!(errno = 0, rtnval = readdir (dirp)) | 3058 while (!(errno = 0, rtnval = readdir (dirp)) |
3065 && (errno == EINTR)) | 3059 && (errno == EINTR)) |
3066 ; | 3060 ; |
3110 return access (path, mode); | 3104 return access (path, mode); |
3111 #endif | 3105 #endif |
3112 } | 3106 } |
3113 | 3107 |
3114 #endif /* ENCAPSULATE_ACCESS */ | 3108 #endif /* ENCAPSULATE_ACCESS */ |
3109 | |
3110 #ifdef HAVE_EACCESS | |
3111 #ifdef ENCAPSULATE_EACCESS | |
3112 | |
3113 int | |
3114 sys_eaccess (CONST char *path, int mode) | |
3115 { | |
3116 PATHNAME_CONVERT_OUT (path); | |
3117 return eaccess (path, mode); | |
3118 } | |
3119 | |
3120 #endif /* ENCAPSULATE_EACCESS */ | |
3121 #endif /* HAVE_EACCESS */ | |
3122 | |
3115 | 3123 |
3116 #ifdef ENCAPSULATE_LSTAT | 3124 #ifdef ENCAPSULATE_LSTAT |
3117 | 3125 |
3118 int | 3126 int |
3119 sys_lstat (CONST char *path, struct stat *buf) | 3127 sys_lstat (CONST char *path, struct stat *buf) |