- Timestamp:
- Jul 14, 2010, 3:54:10 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/blt4/packages/vizservers/pymolproxy/pymolproxy.c
r1719 r1807 1038 1038 } 1039 1039 1040 /* 1041 * LoadPDBCmd -- 1042 * 1043 * Load a PDB file into pymol. There is no good way to load PDB data 1044 * into pymol without using a file. This causes problems in that we 1045 * don't know when pymol is done with the file. So there's always 1046 * a bit of mess left around. We use the same file for every file 1047 * so there's a chance that pymol is still using a file while we're 1048 * overwriting it. 1049 * 1050 * The command expects the number of bytes in the pdb data, the 1051 * name, and the state. 1052 */ 1040 1053 static int 1041 1054 LoadPDBCmd(ClientData clientData, Tcl_Interp *interp, int argc, … … 1046 1059 int state = 1; 1047 1060 int i, defer = 0, push = 0, varg = 1; 1048 1061 int nBytes; 1062 1049 1063 if (proxyPtr == NULL) 1050 1064 return TCL_ERROR; 1051 1065 clear_error(proxyPtr); 1052 pdbdata = name = NULL; /* Suppress compiler warning. */ 1066 pdbdata = name = NULL; /* Suppress compiler warning. */ 1067 nBytes = 0; /* Suppress compiler warning. */ 1053 1068 for(i = 1; i < argc; i++) { 1054 1069 if ( strcmp(argv[i],"-defer") == 0 ) … … 1057 1072 push = 1; 1058 1073 else if (varg == 1) { 1059 pdbdata = argv[i];1074 nBytes = atoi(argv[i]); 1060 1075 varg++; 1061 1076 } else if (varg == 2) { … … 1067 1082 } 1068 1083 } 1069 1070 1084 if (!defer || push) { 1071 1085 proxyPtr->flags |= UPDATE_PENDING; … … 1080 1094 char fileName[200]; 1081 1095 FILE *f; 1082 size_t nBytes;1083 1096 ssize_t nWritten; 1084 1097 char *data; 1098 1099 data = malloc(sizeof(char) * nBytes); 1100 if (data == NULL) { 1101 trace("can't allocate %d bytes for \"pdbdata\" buffer", nBytes); 1102 return TCL_ERROR; 1103 } 1104 if (GetBytes(&proxyPtr->client, data, nBytes) != BUFFER_OK) { 1105 trace("can't read %d bytes for \"pdbdata\" buffer", nBytes); 1106 return TCL_ERROR; 1107 } 1085 1108 sprintf(fileName, "/tmp/pymol%d.pdb", getpid()); 1086 1109 f = fopen(fileName, "w"); … … 1089 1112 perror("pymolproxy"); 1090 1113 } 1091 nBytes = strlen(pdbdata); 1092 nWritten = fwrite(pdbdata, sizeof(char), nBytes, f); 1114 nWritten = fwrite(data, sizeof(char), nBytes, f); 1093 1115 if (nBytes != nWritten) { 1094 1116 trace("short write %d wanted %d bytes", nWritten, nBytes); … … 1844 1866 1845 1867 child = fork(); 1846 1847 1868 if (child < 0) { 1848 1869 fprintf(stderr, "can't fork process: %s\n", strerror(errno)); … … 1943 1964 } else if (status == 0) { 1944 1965 trace("attempting to signal (SIGTERM) pymol server."); 1945 kill(-child, SIGTERM); // kill process group1966 kill(-child, SIGTERM); // Kill process group 1946 1967 alarm(5); 1947 1968 status = waitpid(child, &result, 0); … … 1950 1971 while ((status == -1) && (errno == EINTR)) { 1951 1972 trace("Attempting to signal (SIGKILL) pymol server."); 1952 kill(-child, SIGKILL); // kill process group1973 kill(-child, SIGKILL); // Kill process group 1953 1974 alarm(10); 1954 1975 status = waitpid(child, &result, 0);
Note: See TracChangeset
for help on using the changeset viewer.