-
Notifications
You must be signed in to change notification settings - Fork 1
Tagged task output functions #5
Conversation
Writing a tagged_task now writes in binary, instead of text. Added a tagged_task_get_size function. Removed program stdout to files functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a lot of things wrong here, some cause your bugs and some are grave structural programs.
-
&(struct timespec){.tv_sec = 1, .tv_nsec = 0}
may compile but is not standard C code. If you had ran a debugger through the code (please do it ), you'd realize why it's failing. When setting the time, its value is{.tv_sec = 0, .tv_nsec = 0}
, andtask_t
considers this value of a timestamp to mean an unset time. -
You shouldn't be opening the log file every time you read from or write to it. Create a
log_file_t
type containing the descriptor, pass it around, and close it when needed. Also, please rename your modulelog_file
, asoutput
is way too generic. -
You are writing textual data to the file. Define a binary format and use it.
-
You aren't doing error handling for functions other than
open
. Please do it and seterrno
accordingly. -
Don't use
ftruncate
. UseO_TRUNC
when you open the file. -
Don't print to
stdout
whatever you see in a file when reading. Define some sort of iterator (or reader) and use it outside. This needs to be generic.
In summary, this is pretty much do for a rewrite.
- Renamed module from "output" to "log_file" - Created a "log_file_t" type to pass descriptors around - Added error handling - Added a generic task iterator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed a quite a few things you were doing wrong. We can discuss it personally so that you can learn how to do file management the right way. A few things are still subject to change (e.g.: variable length tasks), but this works as is and can be merged now.
Adds functionality that writes and reads tagged tasks to a binary file.