Pedro, I've attached a patch.
Three pieces : - be able to quit rshd without rebooting my PDA. Do you have another way to do this? - Error handling at the CreatePipe call. Read the comment, it would be better, in my opinion, to be able to send a string back to the rsh. Do you agree; and if so, shall I make changes in that direction ? - Error handling in PipeLib. On my system, ActivateDevice returns with ERROR_DEVICE_IN_USE if all is well, or with ERROR_FILE_NOT_FOUND if the PipeDev.dll is not installed. (Respectively codes 2404 and 2.) Comments ? Danny On Sun, 2007-07-01 at 09:12 +0200, Danny Backx wrote: > On Sat, 2007-06-30 at 22:35 +0100, Pedro Alves wrote: > > > Danny Backx write: > > >> I haven't tried to debug this yet but I can't seem to get rshd to run > > >> > > >> I'm obviously doing something wrong. What should I be doing ? > > >> > > > > I can't see anything obviously wrong with what you're doing. > > Assuming the files you are trying to execute exist, it should be working. > > Silly me. Found it. I had not installed the PipeDev DLL. So I've proven > that the error messages can still be improved :-) > > Sorry about the confusion ! > > Danny -- Danny Backx ; danny.backx - at - scarlet.be ; http://danny.backx.info
Index: rshd/rshd.c =================================================================== --- rshd/rshd.c (revision 1034) +++ rshd/rshd.c (working copy) @@ -510,6 +510,9 @@ return NULL; } + if (strcmp(program, "exit") == 0) + exit(0); + argslen = 0; args = program; /* TODO: program paths with embedded spaces? */ @@ -536,8 +539,33 @@ for (i = 0; i < 3; i++) { wchar_t devname[MAX_PATH]; - if (!CreatePipe (&readh[i], &writeh[i], NULL, 0)) - return NULL; + if (!CreatePipe (&readh[i], &writeh[i], NULL, 0)) { + DWORD err = GetLastError (); + static char x[256]; + sprintf(x, "CreatePipe failed (err %d) : %s", + (int) err, strwinerror (err)); +#if 1 + /* + * We could return 0 here, but there is no way to send + * error strings back to the calling rsh without changing + * the function that calls us. + * This might be a better idea though, we could point + * out that e.g. PipeDev.dll is not installed. + */ + static wchar_t wx[256]; + mbstowcs(wx, x, strlen(x)+1); + MessageBoxW(0, wx, L"rshd", 0); + exit(1); +#else + /* + * We need to be able to use "s2" from the function that + * calls us. + */ + send(s2, x, strlen(x), 0); + send(s2, "\r\n", 2, 0); + return 0; +#endif + } wsprintf (devname, L"dev%d", i); SetPipeTag (readh[i], devname); Index: PipeLib/PipeLib.cpp =================================================================== --- PipeLib/PipeLib.cpp (revision 1034) +++ PipeLib/PipeLib.cpp (working copy) @@ -144,6 +144,18 @@ { PrepareRegistryForInstance (inst, &wsKey); h = ActivateDevice (wsKey, 0); + if (h == 0) { + DWORD e = GetLastError(); + if (e != ERROR_DEVICE_IN_USE) { +#if 0 + wchar_t wm[256]; + wsprintf(wm, L"ActivateDevice (%s) fail %d", wsKey, e); + MessageBoxW(0, wm, L"CreatePipe", 0); +#else + return FALSE; +#endif + } + } RegDeleteKey (HKEY_LOCAL_MACHINE, wsKey); free (wsKey);
signature.asc
Description: This is a digitally signed message part
------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/
_______________________________________________ Cegcc-devel mailing list Cegcc-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/cegcc-devel