Btw, that is the only thing I really disagreed with OP on, the rest seemed just ridiculous.
It's a technical interview, the question should have been technically correct. "What function passes by-reference copies of inodes?"
"lsof just prints open files... you would use netstat, not lsof."
I tried correcting him, but he wouldn't listen and ended the call soon after.
I never received a call back.
~ $ lsof -a -n -c chrome -iTCP:443 | head -2 #sanitized output
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
chrome 1234 me 12u IPv4 12345 0t0 TCP 127.0.0.1:12345->127.0.0.2:https (ESTABLISHED)I personally wouldn't want to work with someone who wasn't able to understand what I mean (in such an obvious case, at least) and wasn't able to answer to that meaning.
(Of course, I'd also personally prefer someone who would point out that this is inaccurate, but do so in a charming and off-hand way, to make me feel comfortable. A high bar, maybe, but for a director that's definitely a bar they should clear).
Remember, you have to walk through the interview thru OP's mindset and how he took into consideration the interviewer's analness.
These functions return information about a file.OS X: (OK, so I lied about the "fine" part)
The stat() function obtains information about the file pointed to by path
Windows, here the VC++ CRT - fantastically poorly described, if you ask me, though of course you shouldn't be using any of this POSIX shit on Windows, so if it confuses anybody enough to make them go and find FindFirstFile then it can only be a good thing: Get status information on a filelstat has the same signature as stat: it passes the stat structure back through an output pointer.
Q: What does lstat return?
A: A struct
>> Wrong, it returns an error code
That type of technical specificity about what well-known functions return is absolutely something I've heard people use as an interview question. Knowing it returns an error code (rather than the value you want) seems like a good indicator of "has actually coded in C" (whereas many other languages return the value you want and raise an exception if it had an error).IIRC, you can return structs from functions in C. You have to access the values in the returned struct with dot notation, of course, like point.x .
Pre-ANSI C may not have had this, but later, it did. Remember reading it in the 2nd (ANSI) edition of the Kernighan & Ritchie C book, and also used it myself in some programs.
https://www.google.co.in/?q=can+you+return+a+structure+in+c
Edit:
Might want to consider the cost of copying, depending on the perf requirements, size of the struct, whether the function call is in a tight loop, etc.
Those functions return a error code, you pass in a stat structure and the function populates that structure.
He was saying (correctly), that they don't return (in the classic C sense) the inode. They return an error code.
To me that is a big difference...
int lstat(const char path, struct stat buf);
vs stat* lstat(const char *path);
2 completely different functions.