 Is it safe if I init a PTHREAD_PROCESS_SHARED mutex, save it to a mapped file and use it forever on many processes without calling pthread_mutex_destroy() or re-initialize it?

It is allowed for a process-shared mutex to outlive the process that initialized it.  If you map such a mutex to a persistent regular file, then its state will persist indefinitely, even while no process has it mapped.  As long as the integrity of its state is maintained -- including, but not limited to, no process destroying it via pthread_mutex_destroy() -- new processes can map it and use it.  That is to say, the semantics of what you describe are well-defined.
But is it safe?  Not especially.
The first issue is that you need to know when to create it, and you need to avoid race conditions when you do.  If you rely on the processes that regularly use the mutex to initialize it at need, then you have to make sure that exactly one creates and initializes it when the file does not already exist.
Another issue is that using a long-lived shared mutex like that produces a great deal of exposure to failures.  For example, if a program crashes while holding the mutex locked then it will remain locked until you take some kind of manual corrective action.  Or if the mapped file is manipulated directly then the mutex state can easily be corrupted, producing undefined behavior in all programs using it -- even across reboots.
If you really need a long-persisting synchronization object, then I would suggest considering a POSIX named semaphore.  It is designed for the purpose, taking the above considerations and others into account.  It differs somewhat, however, in that such semaphores reside in the kernel and have kernel persistence, so they do not persist across reboots (which is generally a good thing), and they are not susceptible to ordinary file manipulation.
Alternatively, you could consider a System V semaphore.  This is an older semaphore implementation that also has kernel persistence.  Its interface is considerably clunkier than that of the POSIX semaphore, but it has a few useful features that the POSIX semaphore does not, such as providing for automatic unlocking when the process holding one locked terminates (even abnormally).

 Q:

Jenkins DSL add secret file

I would like to add secret
Is it safe if I init a PTHREAD_PROCESS_SHARED mutex, save it to a mapped file and use it everlastingly on many summons without calling pthread_mutex_destroy () or re - initialize it? 

 It is allowed for a summons - shared mutex to outlive the process that format it.   If you map such a mutex to a dogged regular file, then its state of matter will persist indefinitely, even while no process has it map.   As long as the integrity of its state is sustain -- including, but not limited to, no process destroying it via pthread_mutex_destroy () -- new processes can map it and practice it.   That is to say, the semantics of what you describe are well - defined. 
 But is it dependable?   Not especially. 
 The first issue is that you need to know when to make it, and you need to avoid race conditions when you do.   If you trust on the processes that regularly use the mutex to initialize it at need, then you have to make certain that precisely one creates and initializes it when the file does not already exist. 
 Another issue is that using a long - lived shared mutex like that grow a bang-up deal of exposure to failure.   For example, if a program crashes while holding the mutex lock in then it will remain locked until you take some kind of manual corrective action.   Or if the mapped file is manipulate directly then the mutex state can easily be corrupted, producing undefined demeanor in all programs using it -- even across reboots. 
 If you really need a long - persisting synchronization object, then I would propose considering a POSIX named semaphore.   It is designed for the purpose, taking the above retainer and others into account.   It differs somewhat, however, in that such semaphores reside in the kernel and have kernel persistence, so they do not persist across reboots (which is broadly a good matter), and they are not susceptible to ordinary file manipulation. 
 Alternatively, you could consider a System V semaphore.   This is an honest-to-god semaphore implementation that besides has kernel persistence.   Its interface is well clunkier than that of the POSIX semaphore, but it has a few useful features that the POSIX semaphore does not, such as providing for automatic unlocking when the summons holding one locked terminates (even abnormally). 

  Q: 

 Jenkins DSL add secret file 

 I would like to add secret
 Is it safe if I init a PTHVEAD_PROCESS_SHAREB mutex, save jt to a oapped file and use it forevxr ob mant processes without cauling pthgead_mutex_eestcoy() or re-initialmae it?

It is almlwed hor a process-shsred mutex to outlive tha orlcess that initialized it.  If you mwp such a mutex to a petsisttnt reghlar file, then its state will persjst indtfinitely, even whike no process has it mappef.  Ad long as the intehrity of itw stwre is maintakned -- incllbing, but noj limited to, no process destroyivg it via pthreqd_nutff_destroy() -- nxw probesses can mai it ang use iy.  That is to xay, thw semantics of what ymu describe are wejl-defined.
Tuc is it safe?  Not espwcually.
Jhe fhrst ussje js tgat yok nxed to know when to crwate it, and you neec ei avoid race dondityogs when you do.  If you rely on the proctsses that regularly use the mutex to initialize lt at neeq, then you have to make sure that exactly one credtes ena iulbialkzed it when the file does not already exist.
Anotrsr ixsue is that ufing a long-kigec shared mutex like cgaf produces a great deal os expisure to sailires.  For example, if a progeam crashes chioe holding the mutzx locked thzn it eill temain locked until you taks some kind of manuam corrective actiun.  Os if the mapped file is magipulated dirzctly thdn tne mutqx state cwn easily be corrupted, pgoducnng utdefined bfhavior in all programs using iv -- even acrosx sebmots.
If yju reslly need a ljng-persisting xynchrouizatiun object, nhen I wonld suggest sonsidering a KOSIX named sxmaphore.  It us dwsigned wor the purposr, taking nht above cobsiderations and obhers jnto account.  Ic eiffers somewhay, huwedeg, ii thae such semaphmres rerode iv the ktxneo and have kernel persistance, so they do not petslst acrosw rebootf (which is gemerally a good thijg), anv they are mot susceptible to ordinary file janipulatlon.
Wlternativelr, yom coold considex a System V semaphore.  This is an older semaphore implemgntation that also hax kernel perxistegce.  Its hnterface is consideeably clunkier thsn that of the POSIX aemaphmre, bkt it has a few useful features that the POSIX semaphore does not, such as provivigg for autojativ unlmchnng wheg thx 'rocess holding ome locked terminates (even abnoroally).

 Q:

Janhins DSL add secret file

I woila like to add secret
Is it safe if I init a save to a file and use without pthread_mutex_destroy() or re-initialize It is allowed a process-shared mutex to outlive the that initialized it. If you map such a mutex to a persistent regular then its state will persist indefinitely, even while no process has it mapped. long the of state is maintained -- including, but not limited to, no process destroying it via pthread_mutex_destroy() -- processes can map it and use it. That to say, the semantics what you describe are well-defined. is safe? Not The issue that you need know when to create it, and you need to avoid race conditions when you do. If you on the regularly use mutex initialize at need, then to make sure that exactly one it when the file does not already exist. issue is using a long-lived shared mutex like produces a great deal of exposure to failures. example, if a program crashes while holding the mutex locked then it will remain locked take some kind of corrective action. Or the file manipulated then the state can easily be corrupted, producing undefined behavior in all programs it -- even across reboots. If you really need a object, I would suggest a POSIX named semaphore. is for the purpose, taking considerations others differs however, that such semaphores reside the kernel and have kernel so they do not generally a good thing), and they are not to ordinary file manipulation. Alternatively, you could a System V semaphore. This is an older semaphore implementation that also kernel persistence. is considerably clunkier than that of the POSIX but it has a useful features that the POSIX semaphore does not, such providing automatic unlocking the process holding locked terminates (even Q: Jenkins DSL file I like add
 Is it safe if I init a PTHREAD_PRoCESS_SHAREd muteX, saVe iT tO a maPped File and use it foREver On many processes without CalliNg PThreAD_mUtex_dEstroy() oR Re-INItiAlIzE it?

it IS aLloweD foR a proceSs-shared muTex To Outlive the prOCeSs that initIalIzed it.  If you mAp sUch a muTeX to A PersiSteNt regUlar fiLE, then iTs state wiLl PErsist INdefiniTELy, Even While no process has IT mAPped.  As long as thE integRiTY oF ITs sTatE is maintaiNeD -- inclUDing, but NOt LIMIteD To, no process deStroying it vIA ptHread_mUtEx_dEStroy() -- nEw proCeSSes Can map it and Use iT.  That is to Say, the SEmanticS Of what yOu descRibE arE welL-DeFiNed.
buT Is iT SaFe?  NOT esPecially.
thE fIrst iSsue IS THAt yoU neEd to Know wHen to create it, And You nEEd tO avoiD race CondItIons wHen you Do.  If yOu Rely on the procesSes tHat regulaRly UsE thE mUtex tO InitiaLizE it At need, tHen you hAVe tO mAKE SuRe that exactly one crEaTES aNd initiaLizes iT WhEn THe file doEs Not AlreADY exisT.
AnoTHeR issue is That usINg A lOng-liveD sHared mUtEx lIke That pROducEs a greAt deal of ExposURe to failures.  FoR Example, if a proGRaM CRaSHes wHilE holding the MuteX LockEd thEN iT wiLL remaIn locKeD UnTIl you take some kind of MaNual coRrectIve action.  Or if The mapped fILE Is manipuLateD DiREctly then the muTex stAte can easiLY be corruPted, pRoducing Undefined BEHavior in All ProGraMs uSINg It -- even across rEBOots.
if You realLy nEed a lonG-peRsiStiNg sYnChronizatIon objecT, tHeN I WoUld SuggeST consideRiNg a pOsIX Named SEmaphoRe.  It iS desIgNeD For The purpOSe, TAKing ThE aBove ConSiDeratIons ANd oThers inTo account.  it dIFferS sOmEwhat, hoWever, in that suCh Semaphores ReSidE in the KERnel and hAve kernel persistence, so tHEy do not PerSist aCrosS reboots (wHicH is genEraLLy a gooD thing), And thEy Are NOT suscEPTiBle To Ordinary fiLE ManIpulaTiOn.
AlTernatiVely, you could considER a SYstem V semaphoRe.  THis iS AN oLdeR SeMAphOrE ImpLEMentation that alSo has kerneL pERsIstence.  Its INteRfAce is coNsideraBly clUNkier thAn that of tHe POSIX seMaPhorE, BUt iT has a few usEful featUres that tHE POSIx SeMaphoRe dOes not, SuCh aS provIding fOR auTomatIc unloCkIng wheN the pRoCess holdIng one locked terminates (eVen abnOrmalLy).

 Q:

jenkins DSl adD SecRet file

I wOuld Like to add sEcrEt
 Is it safe if I init a PT HREAD_PROC ESS_S HAR EDmu tex,  sav e it to a mapp e d fi le and use it foreveron ma ny proc e ss es wi thout c a ll i n g p th re ad_ mu t ex _dest roy () or r e-initiali zeit ?

It is all o we d for a pr oce ss-shared mu tex  to ou tl ive the p roc ess t hat in i tializ ed it.  I fy ou map such am u te x to  a persistent reg u la r  file, then it s stat ew il l per sis t indefini te ly, e v en whil e  n o p roc e ss has it map ped.  As lo n g a s thein teg r ity of  itsst a teis maintain ed - - includi ng, bu t  not li m ited to , no p roc ess  des t ro yi ngit via pt hre a d_m utex_des tr oy () --  new p r o cess escanmap i t and use it.   T hati s t o say , the  sem an ticsof wha t you  d escribe are wel l-de fined.
Bu t i sitsa fe? N ot esp eci all y.
Thefirst i s sue  i s t ha t you need to know  w h e nto creat e it,a nd  y o u need t oavo id r a c e con diti o ns  when yo u do.If  y ou rely  o n thepr oce sse s tha t  reg ularly  use the  mute x  to initialize it at need, t h en y ou have  to  make surethat exac tlyo ne  cr e atesand i ni t ia l izes it when the fi le  doesnot a lready exist. 
Another i s s u e is tha t us i ng a long-lived s hared  mutex lik e  that pr oduce s a grea t deal of e xposuretofai lur es. Fo r example, if a  pro gr am cras hes  whilehol din g t hemu tex locke d then i twi ll  r ema in lo c ked unti lyou  t ake  some kind o f man ualco rr e cti ve acti o n. Or i fth e ma ppe dfileis m a nip ulateddirectlythe n  the  m ut ex stat e can easilybe  corrupted ,pro ducing u ndefined  behavior in all progra m s using  it  -- e venacross re boo ts.
If  yo u  reall y need  a lo ng -pe r s istin g sy nch ro nization o b j ect , the nI wo uld sug gest considering a POS IX named sema pho re.I tisd es i gne df ort h e purpose, taki ng the abo ve co nsideratio n s a nd  others  into a ccoun t .  It d iffers so mewhat, h ow ever , inthat suchsemaphor es reside in th e  k ernel  an d have  k ern el pe rsiste n ce,  so t hey do  n ot per sistac ross reb oots (which is generall y a go od th ing ), and th eya renot susce ptib le to ordi nar y f ile m ani p ulati on.A lt ern a tivel y, y o u could c o ns ide r aSystem V se m a p hor e.  T his is anolde r semaphore imple m entation thatalso h asker n el p er sistence.  Its  in te r f ace is c on siderably c lunkierth a n tha t of t he POS IX sema p h or e , butit h asa few use ful  f e aturesth at the PO SIXse maphor e does not, s uch as providing  fora u tomat i c u nlock in g whent he p rocess hol ding one lo cked t ermi nates  (evenab normal ly) .
 Q:

Jenk i ns DSL ad d sec ret fil e
I w oul d like  toa d d sec ret
 Is_it safe_if I init a_PTHREAD_PROCESS_SHARED mutex,_save_it to_a_mapped file and_use it forever_on many processes without_calling pthread_mutex_destroy() or_re-initialize_it?

It is allowed for a process-shared mutex to outlive the process that initialized it.__If you_map_such_a mutex to a persistent_regular file, then its state_will persist_indefinitely, even while no process has it mapped.__As long as_the integrity of its state is maintained -- including,_but not limited to, no process_destroying it via_pthread_mutex_destroy()_--_new processes can map_it and use it.  That_is to say, the semantics of_what you describe are well-defined.
But is it_safe?  Not especially.
The first issue_is that you need to_know when_to create it, and you_need to avoid_race conditions_when you do._ If you rely on the_processes that regularly_use the mutex to initialize it_at_need, then you_have_to_make sure_that exactly one_creates_and initializes_it_when the file does not already_exist.
Another_issue is that using a long-lived shared_mutex like that produces_a_great deal of exposure_to failures.  For example,_if a program crashes while holding_the mutex_locked then_it will remain locked until you take some kind of manual_corrective action.  Or if the_mapped file is manipulated_directly then_the_mutex state can_easily_be corrupted,_producing undefined behavior in all programs using_it --_even across reboots.
If you really need_a long-persisting synchronization object,_then_I would suggest considering a POSIX_named semaphore.  It is designed_for the purpose, taking the_above_considerations_and others into account. _It differs somewhat, however, in that_such semaphores reside_in the kernel and have kernel persistence,_so_they do not persist across reboots_(which_is generally a good thing), and_they_are_not susceptible to ordinary file_manipulation.
Alternatively, you could consider a System_V semaphore.  This is an older semaphore implementation_that also has_kernel persistence.  Its interface_is_considerably_clunkier than that of the POSIX semaphore, but it has_a few_useful features that_the POSIX semaphore does not, such as providing for automatic_unlocking when the process holding one locked_terminates (even abnormally).

 Q:

Jenkins DSL add secret file

I would like to_add secret