# Arabic translation of manpages # This file is distributed under the same license as the manpages-l10n package. # Copyright © of this file: # زايد السعيدي , 2026. msgid "" msgstr "" "Project-Id-Version: manpages-l10n 4.30.2\n" "POT-Creation-Date: 2026-06-05 06:38+0200\n" "PO-Revision-Date: 2026-06-02 19:37+0400\n" "Last-Translator: Zayed Al-Saidi \n" "Language-Team: Arabic \n" "Language: ar\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=6; plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 " "&& n%100<=10 ? 3 : n%100>=11 && n%100<=99 ? 4 : 5;\n" "X-Generator: Lokalize 23.08.5\n" #. type: TH #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "pthread_cleanup_push" msgstr "pthread_cleanup_push" #. type: TH #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 #: opensuse-tumbleweed #, no-wrap msgid "2025-08-20" msgstr "20 أغسطس 2025" #. type: TH #: archlinux debian-unstable #, no-wrap msgid "Linux man-pages 6.18" msgstr "صفحات دليل لينكس 6.18" #. type: SH #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "NAME" msgstr "الاسم" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "pthread_cleanup_push, pthread_cleanup_pop - push and pop thread cancelation " "clean-up handlers" msgstr "" "pthread_cleanup_push, pthread_cleanup_pop - دفع وسحب معالجات تنظيف إلغاء " "الخيط" #. type: SH #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "LIBRARY" msgstr "المكتبة" #. type: Plain text #: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron #: opensuse-leap-16-1 opensuse-tumbleweed msgid "POSIX threads library (I,\\ I<-lpthread>)" msgstr "مكتبة مسالك POSIX (I،\\ I<-lpthread>)" #. type: SH #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "SYNOPSIS" msgstr "موجز" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "B<#include Epthread.hE>\n" msgstr "B<#include Epthread.hE>\n" #. type: Plain text #: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron #: opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "" "BIB<, void *>IB<);>\n" "BIB<);>\n" msgstr "" "BIB<, void *>IB<);>\n" "BIB<);>\n" #. type: SH #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "DESCRIPTION" msgstr "الوصف" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "These functions manipulate the calling thread's stack of thread-cancelation " "clean-up handlers. A clean-up handler is a function that is automatically " "executed when a thread is canceled (or in various other circumstances " "described below); it might, for example, unlock a mutex so that it becomes " "available to other threads in the process." msgstr "" "تتعامل هذه الدوال مع كومة معالجات تنظيف إلغاء الخيط للخيط المستدعي. معالج " "التنظيف هو دالة تُنفذ آليًا عند إلغاء خيط (أو في ظروف أخرى متنوعة موصوفة " "أدناه)؛ قد يقوم، على سبيل المثال، بفتح قفل كائن المزامنة (mutex) ليصبح متاحًا " "لخيوط أخرى في العملية." #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "The B() function pushes I onto the top of " "the stack of clean-up handlers. When I is later invoked, it will " "be given I as its argument." msgstr "" "تدفع الدالة B() الروتين I إلى أعلى كومة " "معالجات التنظيف. عندما يُستدعى I لاحقًا، سيُعطى I كمعامل له." #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "The B() function removes the routine at the top of the " "stack of clean-up handlers, and optionally executes it if I is " "nonzero." msgstr "" "تزيل الدالة B() الروتين الموجود في أعلى كومة معالجات " "التنظيف، وتنفذه اختياريًا إذا كان I غير صفري." #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "A cancelation clean-up handler is popped from the stack and executed in the " "following circumstances:" msgstr "يُسحب معالج تنظيف الإلغاء من الكومة ويُنفذ في الظروف التالية:" #. type: IP #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "\\[bu]" msgstr "\\[bu]" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "When a thread is canceled, all of the stacked clean-up handlers are popped " "and executed in the reverse of the order in which they were pushed onto the " "stack." msgstr "" "عند إلغاء خيط، تُسحب جميع معالجات التنظيف المكدسة وتُنفذ بترتيب عكسي للترتيب " "الذي دُفعت به إلى الكومة." #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "When a thread terminates by calling B(3), all clean-up " "handlers are executed as described in the preceding point. (Clean-up " "handlers are I called if the thread terminates by performing a " "I from the thread start function.)" msgstr "" "عند إنهاء خيط باستدعاء B(3)، تُنفذ جميع معالجات التنظيف كما هو " "موصوف في النقطة السابقة. (لا تُستدعى معالجات التنظيف إذا أنهى الخيط بتنفيذ " "I من دالة بدء الخيط.)" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "When a thread calls B() with a nonzero I " "argument, the top-most clean-up handler is popped and executed." msgstr "" "عندما يستدعي خيط B() بمعامل I غير صفري، يُسحب " "معالج التنظيف الأعلى ويُنفذ." #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "POSIX.1 permits B() and B() to " "be implemented as macros that expand to text containing \\[aq]B<{>\\[aq] and " "\\[aq]B<}>\\[aq], respectively. For this reason, the caller must ensure " "that calls to these functions are paired within the same function, and at " "the same lexical nesting level. (In other words, a clean-up handler is " "established only during the execution of a specified section of code.)" msgstr "" "يسمح POSIX.1 بتنفيذ B() و B() " "كوحدات ماكرو تتوسع إلى نص يحتوي على \\[aq]B<{>\\[aq] و \\[aq]B<}>\\[aq]، على " "التوالي. لهذا السبب، يجب على المستدعي ضمان أن استدعاءات هذه الدوال مقترنة " "داخل نفس الدالة، وعلى نفس مستوى التداخل المعجمي. (بمعنى آخر، يُنشأ معالج " "التنظيف فقط أثناء تنفيذ قسم محدد من الكود.)" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "Calling B(3) (B(3)) produces undefined results if any " "call has been made to B() or " "B() without the matching call of the pair since the " "jump buffer was filled by B(3) (B(3)). Likewise, " "calling B(3) (B(3)) from inside a clean-up handler " "produces undefined results unless the jump buffer was also filled by " "B(3) (B(3)) inside the handler." msgstr "" "استدعاء B(3) (B(3)) يُنتج نتائج غير محددة إذا تم أي " "استدعاء لـ B() أو B() دون " "الاستدعاء المطابق للزوج منذ أن مُلئ مخزن القفز بواسطة B(3) " "(B(3)). وبالمثل، استدعاء B(3) (B(3)) من داخل " "معالج تنظيف يُنتج نتائج غير محددة ما لم يُملأ مخزن القفز أيضًا بواسطة " "B(3) (B(3)) داخل المعالج." #. type: SH #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "RETURN VALUE" msgstr "قيمة الإرجاع" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "These functions do not return a value." msgstr "لا تعيد هذه الدوال قيمة." #. type: SH #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "ERRORS" msgstr "الأخطاء" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "There are no errors." msgstr "لا توجد أخطاء." #. type: SH #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "ATTRIBUTES" msgstr "السمات" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "For an explanation of the terms used in this section, see B(7)." msgstr "" "للاطلاع على شرح للمصطلحات المستخدمة في هذا القسم، انظر B(7)." #. type: tbl table #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "Interface" msgstr "الواجهة" #. type: tbl table #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "Attribute" msgstr "السمة" #. type: tbl table #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "Value" msgstr "القيمة" #. type: tbl table #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid ".na\n" msgstr ".na\n" #. type: tbl table #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid ".nh\n" msgstr ".nh\n" #. type: tbl table #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "" "B(),\n" "B()" msgstr "" "B(),\n" "B()" #. type: tbl table #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "Thread safety" msgstr "سلامة الخيوط" #. type: tbl table #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "MT-Safe" msgstr "MT-Safe" #. type: SH #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "VERSIONS" msgstr "الإصدارات" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "On glibc, the B() and B() " "functions I implemented as macros that expand to text containing " "\\[aq]B<{>\\[aq] and \\[aq]B<}>\\[aq], respectively. This means that " "variables declared within the scope of paired calls to these functions will " "be visible within only that scope." msgstr "" "في glibc، الدالتان B() و B() " "I<هما> منفذتان كوحدات ماكرو تتوسع إلى نص يحتوي على \\[aq]B<{>\\[aq] و " "\\[aq]B<}>\\[aq]، على التوالي. هذا يعني أن المتغيرات المعلنة ضمن نطاق " "الاستدعاءات المقترنة لهذه الدوال ستكون مرئية فقط ضمن ذلك النطاق." #. The text was actually added in the 2004 TC2 #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "POSIX.1 says that the effect of using I, I, I, or " "I to prematurely leave a block bracketed B() " "and B() is undefined. Portable applications should " "avoid doing this." msgstr "" "يقول POSIX.1 أن تأثير استخدام I أو I أو I أو " "I لمغادرة كتلة محصورة بين B() و " "B() مبكرًا هو غير محدد. يجب على التطبيقات المحمولة تجنب " "فعل ذلك." #. type: SH #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "STANDARDS" msgstr "المعايير" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "POSIX.1-2008." msgstr "POSIX.1-2008." #. type: SH #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "HISTORY" msgstr "التاريخ" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "POSIX.1-2001. glibc 2.0." msgstr "POSIX.1-2001. glibc 2.0." #. type: SH #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "EXAMPLES" msgstr "أمثلة" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "The program below provides a simple example of the use of the functions " "described in this page. The program creates a thread that executes a loop " "bracketed by B() and B(). This " "loop increments a global variable, I, once each second. Depending on " "what command-line arguments are supplied, the main thread sends the other " "thread a cancelation request, or sets a global variable that causes the " "other thread to exit its loop and terminate normally (by doing a I)." msgstr "" "يقدم البرنامج أدناه مثالًا بسيطًا لاستخدام الدوال الموصوفة في هذه الصفحة. ينشئ " "البرنامج خيطًا ينفذ حلقة محصورة بين B() و " "B(). تزيد هذه الحلقة متغيرًا عامًا، I، مرة كل ثانية. " "اعتمادًا على وسائط سطر الأوامر المقدمة، يرسل الخيط الرئيسي للخيط الآخر طلب " "إلغاء، أو يضبط متغيرًا عامًا يتسبب في خروج الخيط الآخر من حلقته وإنهائه بشكل " "طبيعي (عن طريق تنفيذ I)." #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "In the following shell session, the main thread sends a cancelation request " "to the other thread:" msgstr "في جلسة الصدفة التالية، يرسل الخيط الرئيسي طلب إلغاء إلى الخيط الآخر:" #. type: Plain text #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 #: opensuse-tumbleweed #, no-wrap msgid "" "$B< ./a.out>;\n" "New thread started\n" "cnt = 0\n" "cnt = 1\n" "Canceling thread\n" "Called clean-up handler\n" "Thread was canceled; cnt = 0\n" msgstr "" "$B< ./a.out>;\n" "New thread started\n" "cnt = 0\n" "cnt = 1\n" "Canceling thread\n" "Called clean-up handler\n" "Thread was canceled; cnt = 0\n" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "From the above, we see that the thread was canceled, and that the " "cancelation clean-up handler was called and it reset the value of the global " "variable I to 0." msgstr "" "مما سبق، نرى أن الخيط أُلغي، وأن معالج تنظيف الإلغاء استُدعي وأعاد ضبط قيمة " "المتغير العام I إلى 0." #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "In the next run, the main program sets a global variable that causes other " "thread to terminate normally:" msgstr "" "في التشغيل التالي، يضبط البرنامج الرئيس متغيرًا عامًا يتسبب في إنهاء الخيط " "الآخر بشكل طبيعي:" #. type: Plain text #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 #: opensuse-tumbleweed #, no-wrap msgid "" "$B< ./a.out x>;\n" "New thread started\n" "cnt = 0\n" "cnt = 1\n" "Thread terminated normally; cnt = 2\n" msgstr "" "$B< ./a.out x>;\n" "New thread started\n" "cnt = 0\n" "cnt = 1\n" "Thread terminated normally; cnt = 2\n" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "From the above, we see that the clean-up handler was not executed (because " "I was 0), and therefore the value of I was not reset." msgstr "" "مما سبق، نرى أن معالج التنظيف لم يُنفذ (لأن I كانت 0)، " "وبالتالي لم تُعد قيمة I." #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "In the next run, the main program sets a global variable that causes the " "other thread to terminate normally, and supplies a nonzero value for " "I:" msgstr "" "في التشغيل التالي، يضبط البرنامج الرئيس متغيرًا عامًا يتسبب في إنهاء الخيط " "الآخر بشكل طبيعي، ويوفر قيمة غير صفرية لـ I:" #. type: Plain text #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 #: opensuse-tumbleweed #, no-wrap msgid "" "$B< ./a.out x 1>;\n" "New thread started\n" "cnt = 0\n" "cnt = 1\n" "Called clean-up handler\n" "Thread terminated normally; cnt = 0\n" msgstr "" "$B< ./a.out x 1>;\n" "New thread started\n" "cnt = 0\n" "cnt = 1\n" "Called clean-up handler\n" "Thread terminated normally; cnt = 0\n" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "In the above, we see that although the thread was not canceled, the clean-up " "handler was executed, because the argument given to " "B() was nonzero." msgstr "" "في المثال أعلاه، نرى أنه على الرغم من أن الخيط لم يُلغَ، فقد نُفذ معالج " "التنظيف، لأن الوسيط المُعطى لـ B() كان غير صفري." #. type: SS #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "Program source" msgstr "مصدر البرنامج" #. type: Plain text #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 #: opensuse-tumbleweed #, no-wrap msgid "" "#include Eerr.hE\n" "#include Eerrno.hE\n" "#include Epthread.hE\n" "#include Estdio.hE\n" "#include Estdlib.hE\n" "#include Esys/types.hE\n" "#include Eunistd.hE\n" "\\&\n" "static int done = 0;\n" "static int cleanup_pop_arg = 0;\n" "static int cnt = 0;\n" "\\&\n" "static void\n" "cleanup_handler(void *arg)\n" "{\n" " printf(\"Called clean-up handler\\[rs]n\");\n" " cnt = 0;\n" "}\n" "\\&\n" "static void *\n" "thread_start(void *arg)\n" "{\n" " time_t curr;\n" "\\&\n" " printf(\"New thread started\\[rs]n\");\n" "\\&\n" " pthread_cleanup_push(cleanup_handler, NULL);\n" "\\&\n" " curr = time(NULL);\n" "\\&\n" " while (!done) {\n" " pthread_testcancel(); /* A cancelation point */\n" " if (curr E time(NULL)) {\n" " curr = time(NULL);\n" " printf(\"cnt = %d\\[rs]n\", cnt); /* A cancelation point */\n" " cnt++;\n" " }\n" " }\n" "\\&\n" " pthread_cleanup_pop(cleanup_pop_arg);\n" " return NULL;\n" "}\n" "\\&\n" "int\n" "main(int argc, char *argv[])\n" "{\n" " pthread_t thr;\n" " int s;\n" " void *res;\n" "\\&\n" " s = pthread_create(&thr, NULL, thread_start, NULL);\n" " if (s != 0)\n" " errc(EXIT_FAILURE, s, \"pthread_create\");\n" "\\&\n" " sleep(2); /* Allow new thread to run a while */\n" "\\&\n" " if (argc E 1) {\n" " if (argc E 2)\n" " cleanup_pop_arg = atoi(argv[2]);\n" " done = 1;\n" "\\&\n" " } else {\n" " printf(\"Canceling thread\\[rs]n\");\n" " s = pthread_cancel(thr);\n" " if (s != 0)\n" " errc(EXIT_FAILURE, s, \"pthread_cancel\");\n" " }\n" "\\&\n" " s = pthread_join(thr, &res);\n" " if (s != 0)\n" " errc(EXIT_FAILURE, s, \"pthread_join\");\n" "\\&\n" " if (res == PTHREAD_CANCELED)\n" " printf(\"Thread was canceled; cnt = %d\\[rs]n\", cnt);\n" " else\n" " printf(\"Thread terminated normally; cnt = %d\\[rs]n\", cnt);\n" " exit(EXIT_SUCCESS);\n" "}\n" msgstr "" "#include Eerr.hE\n" "#include Eerrno.hE\n" "#include Epthread.hE\n" "#include Estdio.hE\n" "#include Estdlib.hE\n" "#include Esys/types.hE\n" "#include Eunistd.hE\n" "\\&\n" "static int done = 0;\n" "static int cleanup_pop_arg = 0;\n" "static int cnt = 0;\n" "\\&\n" "static void\n" "cleanup_handler(void *arg)\n" "{\n" " printf(\"Called clean-up handler\\[rs]n\");\n" " cnt = 0;\n" "}\n" "\\&\n" "static void *\n" "thread_start(void *arg)\n" "{\n" " time_t curr;\n" "\\&\n" " printf(\"New thread started\\[rs]n\");\n" "\\&\n" " pthread_cleanup_push(cleanup_handler, NULL);\n" "\\&\n" " curr = time(NULL);\n" "\\&\n" " while (!done) {\n" " pthread_testcancel(); /* A cancelation point */\n" " if (curr E time(NULL)) {\n" " curr = time(NULL);\n" " printf(\"cnt = %d\\[rs]n\", cnt); /* A cancelation point */\n" " cnt++;\n" " }\n" " }\n" "\\&\n" " pthread_cleanup_pop(cleanup_pop_arg);\n" " return NULL;\n" "}\n" "\\&\n" "int\n" "main(int argc, char *argv[])\n" "{\n" " pthread_t thr;\n" " int s;\n" " void *res;\n" "\\&\n" " s = pthread_create(&thr, NULL, thread_start, NULL);\n" " if (s != 0)\n" " errc(EXIT_FAILURE, s, \"pthread_create\");\n" "\\&\n" " sleep(2); /* Allow new thread to run a while */\n" "\\&\n" " if (argc E 1) {\n" " if (argc E 2)\n" " cleanup_pop_arg = atoi(argv[2]);\n" " done = 1;\n" "\\&\n" " } else {\n" " printf(\"Canceling thread\\[rs]n\");\n" " s = pthread_cancel(thr);\n" " if (s != 0)\n" " errc(EXIT_FAILURE, s, \"pthread_cancel\");\n" " }\n" "\\&\n" " s = pthread_join(thr, &res);\n" " if (s != 0)\n" " errc(EXIT_FAILURE, s, \"pthread_join\");\n" "\\&\n" " if (res == PTHREAD_CANCELED)\n" " printf(\"Thread was canceled; cnt = %d\\[rs]n\", cnt);\n" " else\n" " printf(\"Thread terminated normally; cnt = %d\\[rs]n\", cnt);\n" " exit(EXIT_SUCCESS);\n" "}\n" #. SRC END #. type: SH #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "SEE ALSO" msgstr "انظر أيضًا" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "B(3), B(3), " "B(3), B(3), B(7)" msgstr "" "B(3)، B(3)، " "B(3)، B(3)، B(7)" #. type: TH #: debian-trixie #, no-wrap msgid "2024-06-15" msgstr "15 يونيو 2024" #. type: TH #: debian-trixie #, no-wrap msgid "Linux man-pages 6.9.1" msgstr "صفحات دليل لينكس 6.9.1" #. type: Plain text #: debian-trixie msgid "POSIX threads library (I, I<-lpthread>)" msgstr "مكتبة مسالك POSIX (I، I<-lpthread>)" #. type: Plain text #: debian-trixie #, no-wrap msgid "" "BIB<)(void *), void *>IB<);>\n" "BIB<);>\n" msgstr "" "BIB<)(void *), void *>IB<);>\n" "BIB<);>\n" #. type: Plain text #: debian-trixie fedora-44 fedora-rawhide #, no-wrap msgid "" "$ B<./a.out>\n" "New thread started\n" "cnt = 0\n" "cnt = 1\n" "Canceling thread\n" "Called clean-up handler\n" "Thread was canceled; cnt = 0\n" msgstr "" "$ B<./a.out>\n" "New thread started\n" "cnt = 0\n" "cnt = 1\n" "Canceling thread\n" "Called clean-up handler\n" "Thread was canceled; cnt = 0\n" #. type: Plain text #: debian-trixie fedora-44 fedora-rawhide #, no-wrap msgid "" "$ B<./a.out x>\n" "New thread started\n" "cnt = 0\n" "cnt = 1\n" "Thread terminated normally; cnt = 2\n" msgstr "" "$ B<./a.out x>\n" "New thread started\n" "cnt = 0\n" "cnt = 1\n" "Thread terminated normally; cnt = 2\n" #. type: Plain text #: debian-trixie fedora-44 fedora-rawhide #, no-wrap msgid "" "$ B<./a.out x 1>\n" "New thread started\n" "cnt = 0\n" "cnt = 1\n" "Called clean-up handler\n" "Thread terminated normally; cnt = 0\n" msgstr "" "$ B<./a.out x 1>\n" "New thread started\n" "cnt = 0\n" "cnt = 1\n" "Called clean-up handler\n" "Thread terminated normally; cnt = 0\n" #. type: Plain text #: debian-trixie fedora-44 fedora-rawhide #, no-wrap msgid "" "#include Eerrno.hE\n" "#include Epthread.hE\n" "#include Estdio.hE\n" "#include Estdlib.hE\n" "#include Esys/types.hE\n" "#include Eunistd.hE\n" "\\&\n" "#define handle_error_en(en, msg) \\[rs]\n" " do { errno = en; perror(msg); exit(EXIT_FAILURE); } while (0)\n" "\\&\n" "static int done = 0;\n" "static int cleanup_pop_arg = 0;\n" "static int cnt = 0;\n" "\\&\n" "static void\n" "cleanup_handler(void *arg)\n" "{\n" " printf(\"Called clean-up handler\\[rs]n\");\n" " cnt = 0;\n" "}\n" "\\&\n" "static void *\n" "thread_start(void *arg)\n" "{\n" " time_t curr;\n" "\\&\n" " printf(\"New thread started\\[rs]n\");\n" "\\&\n" " pthread_cleanup_push(cleanup_handler, NULL);\n" "\\&\n" " curr = time(NULL);\n" "\\&\n" " while (!done) {\n" " pthread_testcancel(); /* A cancelation point */\n" " if (curr E time(NULL)) {\n" " curr = time(NULL);\n" " printf(\"cnt = %d\\[rs]n\", cnt); /* A cancelation point */\n" " cnt++;\n" " }\n" " }\n" "\\&\n" " pthread_cleanup_pop(cleanup_pop_arg);\n" " return NULL;\n" "}\n" "\\&\n" "int\n" "main(int argc, char *argv[])\n" "{\n" " pthread_t thr;\n" " int s;\n" " void *res;\n" "\\&\n" " s = pthread_create(&thr, NULL, thread_start, NULL);\n" " if (s != 0)\n" " handle_error_en(s, \"pthread_create\");\n" "\\&\n" " sleep(2); /* Allow new thread to run a while */\n" "\\&\n" " if (argc E 1) {\n" " if (argc E 2)\n" " cleanup_pop_arg = atoi(argv[2]);\n" " done = 1;\n" "\\&\n" " } else {\n" " printf(\"Canceling thread\\[rs]n\");\n" " s = pthread_cancel(thr);\n" " if (s != 0)\n" " handle_error_en(s, \"pthread_cancel\");\n" " }\n" "\\&\n" " s = pthread_join(thr, &res);\n" " if (s != 0)\n" " handle_error_en(s, \"pthread_join\");\n" "\\&\n" " if (res == PTHREAD_CANCELED)\n" " printf(\"Thread was canceled; cnt = %d\\[rs]n\", cnt);\n" " else\n" " printf(\"Thread terminated normally; cnt = %d\\[rs]n\", cnt);\n" " exit(EXIT_SUCCESS);\n" "}\n" msgstr "" "#include Eerrno.hE\n" "#include Epthread.hE\n" "#include Estdio.hE\n" "#include Estdlib.hE\n" "#include Esys/types.hE\n" "#include Eunistd.hE\n" "\\&\n" "#define handle_error_en(en, msg) \\[rs]\n" " do { errno = en; perror(msg); exit(EXIT_FAILURE); } while (0)\n" "\\&\n" "static int done = 0;\n" "static int cleanup_pop_arg = 0;\n" "static int cnt = 0;\n" "\\&\n" "static void\n" "cleanup_handler(void *arg)\n" "{\n" " printf(\"Called clean-up handler\\[rs]n\");\n" " cnt = 0;\n" "}\n" "\\&\n" "static void *\n" "thread_start(void *arg)\n" "{\n" " time_t curr;\n" "\\&\n" " printf(\"New thread started\\[rs]n\");\n" "\\&\n" " pthread_cleanup_push(cleanup_handler, NULL);\n" "\\&\n" " curr = time(NULL);\n" "\\&\n" " while (!done) {\n" " pthread_testcancel(); /* A cancelation point */\n" " if (curr E time(NULL)) {\n" " curr = time(NULL);\n" " printf(\"cnt = %d\\[rs]n\", cnt); /* A cancelation point */\n" " cnt++;\n" " }\n" " }\n" "\\&\n" " pthread_cleanup_pop(cleanup_pop_arg);\n" " return NULL;\n" "}\n" "\\&\n" "int\n" "main(int argc, char *argv[])\n" "{\n" " pthread_t thr;\n" " int s;\n" " void *res;\n" "\\&\n" " s = pthread_create(&thr, NULL, thread_start, NULL);\n" " if (s != 0)\n" " handle_error_en(s, \"pthread_create\");\n" "\\&\n" " sleep(2); /* Allow new thread to run a while */\n" "\\&\n" " if (argc E 1) {\n" " if (argc E 2)\n" " cleanup_pop_arg = atoi(argv[2]);\n" " done = 1;\n" "\\&\n" " } else {\n" " printf(\"Canceling thread\\[rs]n\");\n" " s = pthread_cancel(thr);\n" " if (s != 0)\n" " handle_error_en(s, \"pthread_cancel\");\n" " }\n" "\\&\n" " s = pthread_join(thr, &res);\n" " if (s != 0)\n" " handle_error_en(s, \"pthread_join\");\n" "\\&\n" " if (res == PTHREAD_CANCELED)\n" " printf(\"Thread was canceled; cnt = %d\\[rs]n\", cnt);\n" " else\n" " printf(\"Thread terminated normally; cnt = %d\\[rs]n\", cnt);\n" " exit(EXIT_SUCCESS);\n" "}\n" #. type: TH #: fedora-44 fedora-rawhide #, no-wrap msgid "2024-12-13" msgstr "13 ديسمبر 2024" #. type: TH #: fedora-44 fedora-rawhide #, no-wrap msgid "Linux man-pages 6.13" msgstr "صفحات دليل لينكس 6.13" #. type: TH #: mageia-cauldron #, no-wrap msgid "Linux man-pages 6.17" msgstr "صفحات دليل لينكس 6.17" #. type: TH #: opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "Linux man-pages (unreleased)" msgstr "صفحات دليل لينكس (لم تصدر بعد)"