Skip to contentSkip to conversation

syscalls/shmget03: Stat and skip existing shared segments

PATCH New Ian May 2 participants 3 messages Aug 4, 2021 – Aug 5, 2021

lore
Share & tools
lore

Ian May

author
#0 lore raw

PATCH 1/1 syscalls/shmget03: Stat and skip existing shared segments

From: Ian May <[email protected]>

Run a SHM_STAT prior to the creation of the shared memory segment. This allows for not failing unexpectedly and still exhausting the proper max shared segments.

---
 testcases/kernel/syscalls/ipc/shmget/shmget03.c | 3 +++
 1 file changed, 3 insertions(+)
testcases/kernel/syscalls/ipc/shmget/shmget03.c +3 -0
index efbc465e1..fe91b6191 100644
@@ -34,6 +34,7 @@ static void verify_shmget(void)
 static void setup(void)
 {
 	int res, num;
+	struct shmid_ds buf;
 
 	shmkey = GETIPCKEY();
 
@@ -41,6 +42,8 @@ static void setup(void)
 
 	queues = SAFE_MALLOC(maxshms * sizeof(int));
 	for (num = 0; num < maxshms; num++) {
+		if(shmctl(num, SHM_STAT, &buf) != -1)
+			continue;
 		res = shmget(shmkey + num, SHM_SIZE, IPC_CREAT | IPC_EXCL | SHM_RW);
 		if (res == -1)
 			tst_brk(TBROK | TERRNO, "shmget failed unexpectedly");
Signature · 1 line
2.25.1
author
#2 lore raw

PATCH 1/1 syscalls/shmget03: Stat and skip existing shared segments

That looks like a good solution!

Thanks,
Ian

Quoted 11 lines · Cyril Hrubis

Hi!
Yang Xu is already working on it, see:

http://patchwork.ozlabs.org/project/ltp/list/?series=256752

Thanks for the effort anyway.

--
Cyril Hrubis
[email protected]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20210805/ea095991/attachment.htm>