- Timestamp:
- Mar 1, 2009 5:42:54 AM (16 years ago)
- Location:
- trunk/src/kash
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kash/Makefile.kmk
r2299 r2302 34 34 kash_ASTOOL = YASM 35 35 kash_DEFS = lint SHELL SMALL 36 kash_DEFS += SH_ STUB_MODE # for the time being.36 kash_DEFS += SH_FORKED_MODE 37 37 kash_DEFS.debug = DEBUG=2 38 38 kash_DEFS.linux = BSD -
trunk/src/kash/shfile.c
r2301 r2302 54 54 */ 55 55 #if K_OS == K_OS_WINDOWS \ 56 || ( !defined(SH_STUB_MODE) \ 57 && !defined(SH_FORKED_MODE)) 56 || !defined(SH_FORKED_MODE) 58 57 # define SHFILE_IN_USE 59 58 #endif … … 600 599 # endif /* K_OS != K_OS_WINDOWS */ 601 600 602 #elif defined(SH_ STUB_MODE) || defined(SH_FORKED_MODE)601 #elif defined(SH_FORKED_MODE) 603 602 fd = open(name, flags, mode); 604 603 #endif … … 681 680 } 682 681 683 #elif defined(SH_STUB_MODE) || defined(SH_FORKED_MODE) 684 # ifdef _MSC_VER 685 rc = _pipe(fds, PIPE_BUF, O_BINARY); 686 # else 682 #elif defined(SH_FORKED_MODE) 687 683 rc = pipe(fds); 688 # endif689 684 #endif 690 685 … … 696 691 { 697 692 int rc; 698 #if defined(SH_ STUB_MODE) || defined(SH_FORKED_MODE)693 #if defined(SH_FORKED_MODE) 699 694 rc = dup(fd); 700 695 … … 729 724 rc = -1; 730 725 731 #elif defined(SH_ STUB_MODE) || defined(SH_FORKED_MODE)726 #elif defined(SH_FORKED_MODE) 732 727 rc = close(fd); 733 728 #endif … … 763 758 rc = -1; 764 759 765 #elif defined(SH_STUB_MODE) || defined(SH_FORKED_MODE) 766 # ifdef _MSC_VER 767 rc = read(fd, buf, (unsigned)len); 768 # else 760 #elif defined(SH_FORKED_MODE) 769 761 rc = read(fd, buf, len); 770 # endif771 762 #endif 772 763 return rc; … … 799 790 rc = -1; 800 791 801 #elif defined(SH_STUB_MODE) || defined(SH_FORKED_MODE) 802 # ifdef _MSC_VER 803 rc = write(fd, buf, (unsigned)len); 804 # else 792 #elif defined(SH_FORKED_MODE) 805 793 rc = write(fd, buf, len); 806 # endif807 794 #endif 808 795 return rc; … … 836 823 rc = -1; 837 824 838 #elif defined(SH_ STUB_MODE) || defined(SH_FORKED_MODE)825 #elif defined(SH_FORKED_MODE) 839 826 rc = lseek(fd, off, whench); 840 827 #endif … … 919 906 rc = -1; 920 907 921 #elif defined(SH_STUB_MODE) || defined(SH_FORKED_MODE) 922 # ifdef _MSC_VER 923 switch (cmd) 924 { 925 /* Just enough F_GETFL/F_SETFL to get along with. */ 926 case F_GETFL: 927 errno = 0; 928 rc = _isatty(fd); 929 if (errno == EBADF) 930 rc = -1; 931 break; 932 933 case F_SETFL: 934 errno = 0; 935 rc = _isatty(fd); 936 if (errno != EBADF) 937 { 938 if (!arg) 939 rc = 0; 940 else 941 { 942 errno = EINVAL; 943 rc = -1; 944 } 945 } 946 else 947 rc = -1; 948 break; 949 950 case F_DUPFD: 951 { 952 /* the brute force approach. */ 953 int i = 0; 954 int fds[256]; 955 for (i = 0; i < 256; i++) 956 { 957 fds[i] = -1; 958 rc = _dup(fd); 959 if (rc >= arg) 960 break; 961 fds[i] = rc; 962 } 963 while (i-- > 0) 964 close(fds[i]); 965 if (rc < arg) 966 { 967 errno = EMFILE; 968 rc = -1; 969 } 970 break; 971 } 972 } 973 # else 908 #elif defined(SH_FORKED_MODE) 974 909 rc = fcntl(fd, cmd, arg); 975 # endif976 910 #endif 977 911 … … 988 922 int shfile_stat(shfdtab *pfdtab, const char *path, struct stat *pst) 989 923 { 990 #if defined(SH_ STUB_MODE) || defined(SH_FORKED_MODE)924 #if defined(SH_FORKED_MODE) 991 925 return stat(path, pst); 992 926 … … 997 931 int shfile_lstat(shfdtab *pfdtab, const char *link, struct stat *pst) 998 932 { 999 #if defined(SH_ STUB_MODE) || defined(SH_FORKED_MODE)933 #if defined(SH_FORKED_MODE) 1000 934 # ifdef _MSC_VER 1001 935 return stat(link, pst); … … 1010 944 int shfile_chdir(shfdtab *pfdtab, const char *path) 1011 945 { 1012 #if defined(SH_ STUB_MODE) || defined(SH_FORKED_MODE)946 #if defined(SH_FORKED_MODE) 1013 947 # ifdef _MSC_VER //??? 1014 948 return chdir(path); … … 1023 957 char *shfile_getcwd(shfdtab *pfdtab, char *buf, int len) 1024 958 { 1025 #if defined(SH_ STUB_MODE) || defined(SH_FORKED_MODE)959 #if defined(SH_FORKED_MODE) 1026 960 return getcwd(buf, len); 1027 961 … … 1032 966 int shfile_access(shfdtab *pfdtab, const char *path, int type) 1033 967 { 1034 #if defined(SH_ STUB_MODE) || defined(SH_FORKED_MODE)968 #if defined(SH_FORKED_MODE) 1035 969 # ifdef _MSC_VER 1036 970 type &= ~X_OK; … … 1048 982 int rc; 1049 983 1050 #if defined(SH_ STUB_MODE) || defined(SH_FORKED_MODE)984 #if defined(SH_FORKED_MODE) 1051 985 rc = isatty(fd); 1052 986 #else … … 1062 996 int rc; 1063 997 1064 #if defined(SH_ STUB_MODE) || defined(SH_FORKED_MODE)998 #if defined(SH_FORKED_MODE) 1065 999 # ifdef _MSC_VER 1066 1000 errno = ENOSYS; … … 1083 1017 int rc; 1084 1018 1085 #if defined(SH_ STUB_MODE) || defined(SH_FORKED_MODE)1019 #if defined(SH_FORKED_MODE) 1086 1020 # ifdef _MSC_VER 1087 1021 errno = ENOSYS; … … 1101 1035 mode_t shfile_get_umask(shfdtab *pfdtab) 1102 1036 { 1103 #if defined(SH_ STUB_MODE) || defined(SH_FORKED_MODE)1037 #if defined(SH_FORKED_MODE) 1104 1038 return 022; 1105 1039 … … 1116 1050 shdir *shfile_opendir(shfdtab *pfdtab, const char *dir) 1117 1051 { 1118 #if defined(SH_ STUB_MODE) || defined(SH_FORKED_MODE)1052 #if defined(SH_FORKED_MODE) 1119 1053 # ifdef _MSC_VER 1120 1054 errno = ENOSYS; … … 1130 1064 shdirent *shfile_readdir(struct shdir *pdir) 1131 1065 { 1132 #if defined(SH_ STUB_MODE) || defined(SH_FORKED_MODE)1066 #if defined(SH_FORKED_MODE) 1133 1067 # ifdef _MSC_VER 1134 1068 errno = ENOSYS; … … 1145 1079 void shfile_closedir(struct shdir *pdir) 1146 1080 { 1147 #if defined(SH_ STUB_MODE) || defined(SH_FORKED_MODE)1081 #if defined(SH_FORKED_MODE) 1148 1082 # ifdef _MSC_VER 1149 1083 errno = ENOSYS; -
trunk/src/kash/shinstance.c
r2301 r2302 697 697 } 698 698 699 #if (defined(SH_STUB_MODE) || defined(SH_FORKED_MODE)) && !defined(_MSC_VER)699 #if defined(SH_FORKED_MODE) && !defined(_MSC_VER) 700 700 rc = sigprocmask(operation, newp, oldp); 701 701 if (!rc && newp) … … 726 726 } 727 727 728 # if defined( SH_STUB_MODE) || defined(_MSC_VER)728 # if defined(_MSC_VER) 729 729 rc = 0; 730 730 # else … … 798 798 * Some other process, call kill where possible 799 799 */ 800 #if defined(SH_ STUB_MODE) || defined(SH_FORKED_MODE)800 #if defined(SH_FORKED_MODE) 801 801 # ifdef _MSC_VER 802 802 errno = ENOSYS; … … 818 818 int rc; 819 819 820 #if defined(SH_ STUB_MODE)820 #if defined(SH_FORKED_MODE) 821 821 # ifdef _MSC_VER 822 822 errno = ENOSYS; … … 837 837 clock_t sh_times(shinstance *psh, shtms *tmsp) 838 838 { 839 #if defined(SH_ STUB_MODE) || defined(SH_FORKED_MODE)839 #if defined(SH_FORKED_MODE) 840 840 (void)psh; 841 841 # ifdef _MSC_VER … … 902 902 pid = shfork_do_it(psh); 903 903 904 #elif defined(SH_ STUB_MODE) || defined(SH_FORKED_MODE)904 #elif defined(SH_FORKED_MODE) 905 905 # ifdef _MSC_VER 906 906 pid = -1; … … 1023 1023 } 1024 1024 1025 #elif defined(SH_ STUB_MODE) || defined(SH_FORKED_MODE)1025 #elif defined(SH_FORKED_MODE) 1026 1026 *statusp = 0; 1027 1027 # ifdef _MSC_VER … … 1046 1046 (void)psh; 1047 1047 1048 #if defined(SH_ STUB_MODE) || defined(SH_FORKED_MODE)1048 #if defined(SH_FORKED_MODE) 1049 1049 _exit(rc); 1050 1050 … … 1071 1071 envp = sh_environ(psh); 1072 1072 1073 #if defined(SH_ STUB_MODE) || defined(SH_FORKED_MODE)1073 #if defined(SH_FORKED_MODE) 1074 1074 errno = 0; 1075 1075 # ifdef _MSC_VER … … 1079 1079 { 1080 1080 TRACE2((psh, "sh_execve: child exited, rc=%d. (errno=%d)\n", rc, errno)); 1081 exit( rc);1081 exit((int)rc); 1082 1082 } 1083 1083 # else … … 1095 1095 uid_t sh_getuid(shinstance *psh) 1096 1096 { 1097 #if defined(SH_ STUB_MODE) || defined(SH_FORKED_MODE)1097 #if defined(SH_FORKED_MODE) 1098 1098 # ifdef _MSC_VER 1099 1099 uid_t uid = 0; … … 1112 1112 uid_t sh_geteuid(shinstance *psh) 1113 1113 { 1114 #if defined(SH_ STUB_MODE) || defined(SH_FORKED_MODE)1114 #if defined(SH_FORKED_MODE) 1115 1115 # ifdef _MSC_VER 1116 1116 uid_t euid = 0; … … 1129 1129 gid_t sh_getgid(shinstance *psh) 1130 1130 { 1131 #if defined(SH_ STUB_MODE) || defined(SH_FORKED_MODE)1131 #if defined(SH_FORKED_MODE) 1132 1132 # ifdef _MSC_VER 1133 1133 gid_t gid = 0; … … 1146 1146 gid_t sh_getegid(shinstance *psh) 1147 1147 { 1148 #if defined(SH_ STUB_MODE) || defined(SH_FORKED_MODE)1148 #if defined(SH_FORKED_MODE) 1149 1149 # ifdef _MSC_VER 1150 1150 gid_t egid = 0; … … 1165 1165 pid_t pid; 1166 1166 1167 #if defined(SH_ STUB_MODE) || defined(SH_FORKED_MODE)1167 #if defined(SH_FORKED_MODE) 1168 1168 # ifdef _MSC_VER 1169 1169 pid = _getpid(); … … 1180 1180 pid_t sh_getpgrp(shinstance *psh) 1181 1181 { 1182 #if defined(SH_ STUB_MODE) || defined(SH_FORKED_MODE)1182 #if defined(SH_FORKED_MODE) 1183 1183 # ifdef _MSC_VER 1184 1184 pid_t pgrp = _getpid(); … … 1197 1197 pid_t sh_getpgid(shinstance *psh, pid_t pid) 1198 1198 { 1199 #if defined(SH_ STUB_MODE) || defined(SH_FORKED_MODE)1199 #if defined(SH_FORKED_MODE) 1200 1200 # ifdef _MSC_VER 1201 1201 pid_t pgid = pid; … … 1214 1214 int sh_setpgid(shinstance *psh, pid_t pid, pid_t pgid) 1215 1215 { 1216 #if defined(SH_ STUB_MODE) || defined(SH_FORKED_MODE)1216 #if defined(SH_FORKED_MODE) 1217 1217 # ifdef _MSC_VER 1218 1218 int rc = -1; … … 1234 1234 pid_t pgrp; 1235 1235 1236 #if defined(SH_ STUB_MODE) || defined(SH_FORKED_MODE)1236 #if defined(SH_FORKED_MODE) 1237 1237 # ifdef _MSC_VER 1238 1238 pgrp = -1; … … 1255 1255 TRACE2((psh, "sh_tcsetpgrp(%d, %d)\n", fd, pgrp)); 1256 1256 1257 #if defined(SH_ STUB_MODE) || defined(SH_FORKED_MODE)1257 #if defined(SH_FORKED_MODE) 1258 1258 # ifdef _MSC_VER 1259 1259 rc = -1; … … 1273 1273 int sh_getrlimit(shinstance *psh, int resid, shrlimit *limp) 1274 1274 { 1275 #if defined(SH_ STUB_MODE) || defined(SH_FORKED_MODE)1275 #if defined(SH_FORKED_MODE) 1276 1276 # ifdef _MSC_VER 1277 1277 int rc = -1; … … 1293 1293 int sh_setrlimit(shinstance *psh, int resid, const shrlimit *limp) 1294 1294 { 1295 #if defined(SH_ STUB_MODE) || defined(SH_FORKED_MODE)1295 #if defined(SH_FORKED_MODE) 1296 1296 # ifdef _MSC_VER 1297 1297 int rc = -1;
Note:
See TracChangeset
for help on using the changeset viewer.