Skip to content

Commit

Permalink
Fixed C-d and empty line error
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@898 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Peter Aronsson committed Jan 19, 2003
1 parent ced2b89 commit cc29d87
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions mosh/src/mosh.cpp
Expand Up @@ -55,7 +55,7 @@ int main(int argc, char* argv[])
{
// Starting background server.
char systemstr[255];
sprintf(systemstr,"%s/../modeq/modeq +d=interactive > %s/error.log &",
sprintf(systemstr,"%s/../modeq/modeq +d=interactive > %s/error.log 2>&1 &",
moshhome,moshhome);
int res = system(systemstr);
std::cout << "Started server using:"<< systemstr << "\n res = " << res << std::endl;
Expand Down Expand Up @@ -114,22 +114,24 @@ int main(int argc, char* argv[])
char* line = readline(">>> ");
if ( line == 0 || strcmp(line,"quit()") == 0 ) {
done =true;
if (line == 0) line ="quit()";
if (line == 0) { line = "quit()"; }
}
add_history(line);
int nbytes = write(sock,line,strlen(line)+1);
if (nbytes == 0) {
std::cout << "Error writing to server" << std::endl;
done = true;
break;
if (strcmp(line,"\n")!=0 && strcmp(line,"") != 0) {
add_history(line);
int nbytes = write(sock,line,strlen(line)+1);
if (nbytes == 0) {
std::cout << "Error writing to server" << std::endl;
done = true;
break;
}
int recvbytes = read(sock,buf,40000);
if (recvbytes == 0) {
std::cout << "Recieved 0 bytes, exiting" << std::endl;
done = true;
break;
}
std::cout << buf;
}
int recvbytes = read(sock,buf,40000);
if (recvbytes == 0) {
std::cout << "Recieved 0 bytes, exiting" << std::endl;
done = true;
break;
}
std::cout << buf;
free(line);
}
close (sock);
Expand Down

0 comments on commit cc29d87

Please sign in to comment.