jacereda / fsatrace

Filesystem access tracer
ISC License
81 stars 12 forks source link

Error should be more informative #4

Closed ndmitchell closed 8 years ago

ndmitchell commented 8 years ago

I sometimes get:

Fatal: fsatrace.c:39: CreateProcessW(0, cmd, 0, 0, 0, CREATE_SUSPENDED, 0, 0, &si, &pi), err: 2

It would be really useful if in those circumstances it could also print the command line used, since that can help with debugging various escaping issues (which I think is the problem I'm having here!)

jacereda commented 8 years ago

Is this enough?

https://github.com/jacereda/fsatrace/commit/4e771eb57d16ba21887b7c1fd7aa6d9e578a0424

If you need the full composed line passed to CreateProcessW just tell me.

ndmitchell commented 8 years ago

I now get:

fsatrace.exe(9988): error: forking process:
0:cmd /c echo 1

Which is still confusing since I don't know why it fails. I guess the fully composed line would be helpful here. The 0: also seems somewhat confusing.

jacereda commented 8 years ago

You should probably pass:

0:cmd
1:/c
2:echo 1
jacereda commented 8 years ago

Keep in mind that if we switch to _spawnvp() or similar for process execution that's what the arguments should look like, a single argument won't work.

ndmitchell commented 8 years ago

Ah, now I understand the 0 bit. Maybe even argv[0] = cmd ? Yes, I split up the cmd from the /c and it works.

ndmitchell commented 8 years ago

Yep, entirely my bug, I was just having difficulty tracking back through 3 layers of cmd/Haskell/fsatrace to figure what I ended up with.

jacereda commented 8 years ago

I changed the error messages to say argv[i].

ndmitchell commented 8 years ago

What about argv[i]=... instead of argv[i]:? Since I have Windows, I get argv[i]:C:\foo, which looks a bit confusing, but not terrible if you'd prefer the : style.

jacereda commented 8 years ago

Done

ndmitchell commented 8 years ago

Awesome, thanks a lot.