shmget的的手冊頁說:
除了上述標誌, shmflg的至少顯著9位指定授予所有者,組和 其他用戶的權限。這些位具有相同的格式,並且與open(2)的mode參數 具有相同的含義。
因此,讓我們檢查的開放手冊頁:
The following symbolic constants are provided for mode:
- S_IRWXU 00700 user (file owner) has read, write, and execute permission
- S_IRUSR 00400 user has read permission
- S_IWUSR 00200 user has write permission
- S_IXUSR 00100 user has execute permission
- S_IRWXG 00070 group has read, write, and execute permission
- S_IRGRP 00040 group has read permission
- S_IWGRP 00020 group has write permission
- S_IXGRP 00010 group has execute permission
- S_IRWXO 00007 others have read, write, and execute permission
- S_IROTH 00004 others have read permission
- S_IWOTH 00002 others have write permission
- S_IXOTH 00001 others have execute permission
整數值編碼爲二進制1.1億,對應於標誌,即S_IRUSR|S_IWUSR
:
誰寫這段代碼倖免2分鐘他的生命,浪費更多的其他許多人的生命的時候,包括我在內。
恭喜。 :)
編輯:感謝@Fabio圖拉蒂您指出了一個重大錯誤;)
確實101111110對應的標誌374?我會說它是576.那就是:用戶已經讀取並執行,組已經讀取,寫入和執行,而其他人已經讀取和寫入。甚至在此之前:你確定384是以二進制方式編碼的嗎?它不應該是110000000?也就是說,用戶有閱讀和寫作,而其他人都沒有?你的號碼是101111110,實際上是382的二進制編碼,而不是384.你能檢查嗎? –
@FabioTurati我錯誤地輸入了Python中的最初數字,並從那裏開始走下坡路。感謝您指出錯誤:) –
不客氣。順便說一句好的答案! –