-
Notifications
You must be signed in to change notification settings - Fork 37
Implemented lsipc
#253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented lsipc
#253
Conversation
FYI, in order to test the tool, I had to artificially create some semaphores and message queues on my system. Here follows are two C programs I wrote for just that. The programs create the semaphores and the message queues, then they wait indefinitely for // sem.c
#include <assert.h>
#include <fcntl.h>
#include <signal.h>
#include <stdio.h>
#include <sys/sem.h>
#include <sys/stat.h>
#include <unistd.h>
static int exit_now = 0;
void sigint_handler(int signal) { exit_now = 1; }
int main() {
signal(SIGINT, sigint_handler);
int s = semget(IPC_PRIVATE, 3, IPC_CREAT | IPC_EXCL | S_IRUSR | S_IWUSR);
assert(s != -1);
printf("# Semaphores created.\n");
semctl(s, 0, SETVAL, (int)7);
semctl(s, 1, SETVAL, (int)0);
semctl(s, 2, SETVAL, (int)500);
printf("# Semaphores configured.\n");
while (!exit_now) {
usleep(1000 * 1000);
}
semctl(s, 0, IPC_RMID);
printf("# Semaphores deleted.\n");
return 0;
} // msq.c
#include <assert.h>
#include <fcntl.h>
#include <signal.h>
#include <stdio.h>
#include <sys/msg.h>
#include <sys/stat.h>
#include <unistd.h>
struct msgbuf {
long mtype; /* message type, must be > 0 */
char mtext[32]; /* message data */
};
static int exit_now = 0;
void sigint_handler(int signal) { exit_now = 1; }
int main() {
signal(SIGINT, sigint_handler);
int q = msgget(IPC_PRIVATE, IPC_CREAT | IPC_EXCL | S_IRUSR | S_IWUSR);
assert(q != -1);
printf("# Message queue created.\n");
struct msgbuf msg0 = {7, "Hello!"};
msgsnd(q, &msg0, 32, 0);
msgsnd(q, &msg0, 32, 0);
msgsnd(q, &msg0, 32, 0);
printf("# Message queue configured.\n");
while (!exit_now) {
usleep(1000 * 1000);
}
msgctl(q, IPC_RMID, NULL);
printf("# Message queue deleted.\n");
return 0;
} |
Could you please add it to the CI ? thanks! |
I added sequences like this to the CI configuration: - run: sudo apt-get update --quiet
- run: sudo apt-get install --quiet --no-install-recommends --assume-yes libclang-dev libc6-dev libsmartcols-dev |
could you please fix that ? :) |
Done. |
@sylvestre, I still see failures in CI for Windows and MacOS X. Isn't this project Linux-specific? |
b600653
to
2d3e3cb
Compare
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.
Pull Request Overview
This pull request introduces a new lsipc command along with its supporting modules and configuration updates for listing IPC facilities. Key changes include:
- Implementation of core functionality in multiple modules (utils, smartcols, message_queue, display, column).
- Addition of new Cargo.toml configuration and documentation (lsipc.md) for the command.
- Updates to CI workflows and top‑level project configuration to include lsipc.
Reviewed Changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
src/uu/lsipc/src/utils.rs | Utility functions for system page size, local time conversion, and file I/O. |
src/uu/lsipc/src/smartcols.rs | Initialization and operations for smartcols table handling. |
src/uu/lsipc/src/message_queue.rs | Parsing and processing of System V IPC message queue information. |
src/uu/lsipc/src/main.rs | Command entry point invoking the new lsipc functionality. |
src/uu/lsipc/src/errors.rs | Custom error types and error‐generating helper functions. |
src/uu/lsipc/src/display.rs | Formatting utilities for time, size, and permissions display. |
src/uu/lsipc/src/column.rs | Definitions for column metadata and output customization. |
src/uu/lsipc/lsipc.md | User documentation for the lsipc command. |
src/uu/lsipc/Cargo.toml | Package configuration for the new lsipc crate. |
Cargo.toml | Top‑level workspace manifest updated to include lsipc. |
.github/workflows/ci.yml | CI configuration updated to install additional OS dependencies as needed. |
Files not reviewed (1)
- src/uu/lsipc/after-help.txt: Language not supported
Comments suppressed due to low confidence (1)
src/uu/lsipc/src/message_queue.rs:285
- [nitpick] Consider using a more descriptive variable name or adding an inline comment to explain the conversion and filtering logic for msqid to improve code readability.
.filter(|(msqid, _stat)| c_uint::try_from(*msqid).is_ok_and(|msqid| msqid == id))
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #253 +/- ##
===========================
===========================
☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Dependencies I had to do:
smartcols-sys
.Closes #19.