<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Aldora</title>
    <description>The latest articles on DEV Community by Aldora (@aldora).</description>
    <link>https://dev.to/aldora</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F352387%2F19d0e0cf-8178-470c-b6ad-8f67a176b0dd.jpg</url>
      <title>DEV Community: Aldora</title>
      <link>https://dev.to/aldora</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aldora"/>
    <language>en</language>
    <item>
      <title>Online Tool: sql schema to entity</title>
      <dc:creator>Aldora</dc:creator>
      <pubDate>Tue, 09 Aug 2022 05:08:00 +0000</pubDate>
      <link>https://dev.to/aldora/online-tool-sql-schema-to-entity-218m</link>
      <guid>https://dev.to/aldora/online-tool-sql-schema-to-entity-218m</guid>
      <description>&lt;p&gt;&lt;a href="https://converter.aldoraweb.com:"&gt;https://converter.aldoraweb.com:&lt;/a&gt; It converts the sql table to entity, saves your time&lt;/p&gt;

&lt;p&gt;This is my first site, built with Nextjs.&lt;br&gt;
It can convert mysql schema to entity(something I need while work)&lt;br&gt;
Enjoy it~&lt;br&gt;
Looking forward to feedback.&lt;/p&gt;

</description>
      <category>showdev</category>
      <category>javascript</category>
      <category>nextjs</category>
    </item>
    <item>
      <title>My new site: https://www.aldoraweb.com</title>
      <dc:creator>Aldora</dc:creator>
      <pubDate>Thu, 09 Jun 2022 03:08:39 +0000</pubDate>
      <link>https://dev.to/aldora/my-new-site-httpswwwaldorawebcom-29pk</link>
      <guid>https://dev.to/aldora/my-new-site-httpswwwaldorawebcom-29pk</guid>
      <description>&lt;p&gt;I'm building my own site with ghost: &lt;a href="https://www.aldoraweb.com"&gt;https://www.aldoraweb.com&lt;/a&gt;&lt;br&gt;
Welcome~&lt;/p&gt;

</description>
      <category>sideprojects</category>
    </item>
    <item>
      <title>Common Devices CSS Width</title>
      <dc:creator>Aldora</dc:creator>
      <pubDate>Mon, 14 Feb 2022 08:29:58 +0000</pubDate>
      <link>https://dev.to/aldora/common-devices-css-width-2o3e</link>
      <guid>https://dev.to/aldora/common-devices-css-width-2o3e</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---rnaCkFu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vnc7yl3juvywc0083s58.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---rnaCkFu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vnc7yl3juvywc0083s58.png" alt="devices css width" width="880" height="305"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;*&lt;a href="https://www.bitdegree.org/learn/responsive-media"&gt;source&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Device resolution is not css resolution</title>
      <dc:creator>Aldora</dc:creator>
      <pubDate>Mon, 14 Feb 2022 07:27:50 +0000</pubDate>
      <link>https://dev.to/aldora/device-resolution-is-not-css-resolution-4ng</link>
      <guid>https://dev.to/aldora/device-resolution-is-not-css-resolution-4ng</guid>
      <description>&lt;p&gt;For more info: &lt;a href="https://dev.toUnderstanding%20the%20Difference%20Between%20CSS%20Resolution%20and%20Device%20Resolution"&gt;click here&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>MySql: Locks on (not unique)Index in Repeatable Read Transaction</title>
      <dc:creator>Aldora</dc:creator>
      <pubDate>Tue, 25 Jan 2022 08:01:17 +0000</pubDate>
      <link>https://dev.to/aldora/mysql-locks-on-not-uniqueindex-in-repeatable-read-transaction-40hc</link>
      <guid>https://dev.to/aldora/mysql-locks-on-not-uniqueindex-in-repeatable-read-transaction-40hc</guid>
      <description>&lt;p&gt;&lt;em&gt;* For MySql 8(the version this article uses), we can view locks in table: &lt;code&gt;performance_schema.data_locks&lt;/code&gt;. For versions prior to version 8, they are in&lt;br&gt;
  table &lt;code&gt;information_schema.innodb_locks&lt;/code&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key point: Gap lock would be created. Be careful, a gap, not just the index you are searching&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;For a unique index with a unique search condition, InnoDB locks only the index record found, not the gap before it;&lt;br&gt;
For other search conditions(not unique index), InnoDB locks the index range scanned, using gap locks or next-key locks to block insertions by other sessions into the gaps covered by the range.(&lt;a href="https://dev.mysql.com/doc/refman/8.0/en/innodb-transaction-isolation-levels.html"&gt;source&lt;/a&gt;)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;p&gt;We create &lt;code&gt;payment&lt;/code&gt; table, as following image shows. Column &lt;code&gt;state&lt;/code&gt; is a normal index. &lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;id&lt;/th&gt;
&lt;th&gt;description&lt;/th&gt;
&lt;th&gt;state&lt;/th&gt;
&lt;th&gt;customer_id&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;payment1&lt;/td&gt;
&lt;td&gt;102&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;payment2&lt;/td&gt;
&lt;td&gt;100&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;payment3&lt;/td&gt;
&lt;td&gt;104&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;payment4&lt;/td&gt;
&lt;td&gt;106&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;payment3&lt;/td&gt;
&lt;td&gt;104&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h5&gt;
  
  
  Example1
&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;query&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  START TRANSACTION;
  SELECT * FROM payment WHERE state = 104 FOR UPDATE;(or UPDATE payment SET description = "updated from console" WHERE state = 104)
  SELECT OBJECT_NAME, INDEX_NAME, LOCK_TYPE, LOCK_MODE, LOCK_STATUS, LOCK_DATA FROM performance_schema.data_locks;
  COMMIT ;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;lock&lt;/strong&gt; from &lt;code&gt;performance_schema.data_locks&lt;/code&gt;:&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;ENGINE&lt;/th&gt;
&lt;th&gt;OBJECT_NAME&lt;/th&gt;
&lt;th&gt;INDEX_NAME&lt;/th&gt;
&lt;th&gt;LOCK_TYPE&lt;/th&gt;
&lt;th&gt;LOCK_MODE&lt;/th&gt;
&lt;th&gt;LOCK_STATUS&lt;/th&gt;
&lt;th&gt;LOCK_DATA&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;INNODB&lt;/td&gt;
&lt;td&gt;payment&lt;/td&gt;
&lt;td&gt;NULL&lt;/td&gt;
&lt;td&gt;TABLE&lt;/td&gt;
&lt;td&gt;IX&lt;/td&gt;
&lt;td&gt;GRANTED&lt;/td&gt;
&lt;td&gt;NULL&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;INNODB&lt;/td&gt;
&lt;td&gt;payment&lt;/td&gt;
&lt;td&gt;state_index&lt;/td&gt;
&lt;td&gt;RECORD&lt;/td&gt;
&lt;td&gt;X&lt;/td&gt;
&lt;td&gt;GRANTED&lt;/td&gt;
&lt;td&gt;104, 3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;INNODB&lt;/td&gt;
&lt;td&gt;payment&lt;/td&gt;
&lt;td&gt;state_index&lt;/td&gt;
&lt;td&gt;RECORD&lt;/td&gt;
&lt;td&gt;X&lt;/td&gt;
&lt;td&gt;GRANTED&lt;/td&gt;
&lt;td&gt;104, 5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;INNODB&lt;/td&gt;
&lt;td&gt;payment&lt;/td&gt;
&lt;td&gt;PRIMARY&lt;/td&gt;
&lt;td&gt;RECORD&lt;/td&gt;
&lt;td&gt;X,REC_NOT_GAP&lt;/td&gt;
&lt;td&gt;GRANTED&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;INNODB&lt;/td&gt;
&lt;td&gt;payment&lt;/td&gt;
&lt;td&gt;PRIMARY&lt;/td&gt;
&lt;td&gt;RECORD&lt;/td&gt;
&lt;td&gt;X,REC_NOT_GAP&lt;/td&gt;
&lt;td&gt;GRANTED&lt;/td&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;INNODB&lt;/td&gt;
&lt;td&gt;payment&lt;/td&gt;
&lt;td&gt;state_index&lt;/td&gt;
&lt;td&gt;RECORD&lt;/td&gt;
&lt;td&gt;X,GAP&lt;/td&gt;
&lt;td&gt;GRANTED&lt;/td&gt;
&lt;td&gt;106, 4&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;locks break down:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;MySql add row locks on id=3, id=5 as they have 104 state, which means others transactions can't update them.&lt;/li&gt;
&lt;li&gt;Mysql not only locks rows with state 104, it also crates a gap lock between state 104 and its next value(106, not inclusive) in the table, and it means insertion with state less than 106, greater than 104 would fail. For example, an insertion with state 105 would fail, but with state 106 would succeed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;IX- intention lock&lt;/strong&gt;, table-level locks that indicate which type of lock (shared or exclusive) a transaction requires later for a row in a table. &lt;a href="https://dev.mysql.com/doc/refman/8.0/en/innodb-locking.html#innodb-intention-locks"&gt;click here for more&lt;/a&gt;
&amp;gt; The intention locking protocol is as follows:
&amp;gt;
&amp;gt; Before a transaction can acquire a shared lock on a row in a table, it must first acquire an IS lock or stronger on
the table.
&amp;gt;
&amp;gt; Before a transaction can acquire an exclusive lock on a row in a table, it must first acquire an IX lock on the
table.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;X- exclusive lock&lt;/strong&gt;, permits the transaction that holds the lock to update or delete a row. &lt;a href="https://dev.mysql.com/doc/refman/8.0/en/innodb-locking.html#innodb-shared-exclusive-locks"&gt;Click here for more&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;REC_NOT_GAP&lt;/strong&gt; indicates a record-only lock, and means the S lock is a record lock.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GAP: gap lock&lt;/strong&gt;, a gap between index records, or a lock on the gap before the first or after the last index record. It should be noted that the row marked as gap lock is not included as lock, so it means it still can be updated or insert.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;
  
  
  Example2
&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;query&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  START TRANSACTION;
  SELECT * FROM payment WHERE state = 106 FOR UPDATE;(or UPDATE payment SET description = "updated from console" WHERE state = 106)
  SELECT OBJECT_NAME, INDEX_NAME, LOCK_TYPE, LOCK_MODE, LOCK_STATUS, LOCK_DATA FROM performance_schema.data_locks;
  COMMIT ;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;lock&lt;/strong&gt; from &lt;code&gt;performance_schema.data_locks&lt;/code&gt;:&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;ENGINE&lt;/th&gt;
&lt;th&gt;OBJECT_NAME&lt;/th&gt;
&lt;th&gt;INDEX_NAME&lt;/th&gt;
&lt;th&gt;LOCK_TYPE&lt;/th&gt;
&lt;th&gt;LOCK_MODE&lt;/th&gt;
&lt;th&gt;LOCK_STATUS&lt;/th&gt;
&lt;th&gt;LOCK_DATA&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;INNODB&lt;/td&gt;
&lt;td&gt;payment&lt;/td&gt;
&lt;td&gt;NULL&lt;/td&gt;
&lt;td&gt;TABLE&lt;/td&gt;
&lt;td&gt;IX&lt;/td&gt;
&lt;td&gt;GRANTED&lt;/td&gt;
&lt;td&gt;NULL&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;INNODB&lt;/td&gt;
&lt;td&gt;payment&lt;/td&gt;
&lt;td&gt;state_index&lt;/td&gt;
&lt;td&gt;RECORD&lt;/td&gt;
&lt;td&gt;X&lt;/td&gt;
&lt;td&gt;GRANTED&lt;/td&gt;
&lt;td&gt;supremum pseudo-record&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;INNODB&lt;/td&gt;
&lt;td&gt;payment&lt;/td&gt;
&lt;td&gt;state_index&lt;/td&gt;
&lt;td&gt;RECORD&lt;/td&gt;
&lt;td&gt;X&lt;/td&gt;
&lt;td&gt;GRANTED&lt;/td&gt;
&lt;td&gt;106, 4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;INNODB&lt;/td&gt;
&lt;td&gt;payment&lt;/td&gt;
&lt;td&gt;PRIMARY&lt;/td&gt;
&lt;td&gt;RECORD&lt;/td&gt;
&lt;td&gt;X,REC_NOT_GAP&lt;/td&gt;
&lt;td&gt;GRANTED&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;locks break down:

&lt;ul&gt;
&lt;li&gt;The SELECT FOR UPDATE is locking between 106 and the next value in the payment table. Since there is no next-value, it is locking until the &lt;strong&gt;supremum pseudo-record&lt;/strong&gt;. In the above example, any value above 106 can't be inserted or updated.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Related Materials:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dev.mysql.com/doc/refman/8.0/en/innodb-locking.html#innodb-gap-locks"&gt;InnoDB Locking&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.mysql.com/doc/refman/8.0/en/innodb-transaction-isolation-levels.html"&gt;Transaction Isolation Levels&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/codex/understand-the-basics-of-locks-and-deadlocks-in-mysql-part-i-92f229db0a"&gt;Understand the basics of locks and deadlocks in MySQL (Part I)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>mysql</category>
    </item>
    <item>
      <title>Book :Textbook for System Design Interviews</title>
      <dc:creator>Aldora</dc:creator>
      <pubDate>Wed, 12 Jan 2022 05:40:00 +0000</pubDate>
      <link>https://dev.to/aldora/book-textbook-for-system-design-interviews-4dd</link>
      <guid>https://dev.to/aldora/book-textbook-for-system-design-interviews-4dd</guid>
      <description>&lt;p&gt;Recomendation: Textbook for System Design Interviews: &lt;a href="https://systemdesign.org"&gt;https://systemdesign.org&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cP1d5jIR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zv1iro58hk83vcyb31i5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cP1d5jIR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zv1iro58hk83vcyb31i5.png" alt="Image description" width="880" height="733"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Z8srY8tn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7fxly9vk3d1ywgd820ud.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Z8srY8tn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7fxly9vk3d1ywgd820ud.png" alt="Image description" width="880" height="664"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>systems</category>
      <category>design</category>
    </item>
    <item>
      <title>The more I learn Java, the more I feel that feel how loose PHP is.</title>
      <dc:creator>Aldora</dc:creator>
      <pubDate>Fri, 07 May 2021 05:12:12 +0000</pubDate>
      <link>https://dev.to/aldora/the-more-i-learn-java-the-more-i-feel-that-feel-how-loose-php-is-4hi6</link>
      <guid>https://dev.to/aldora/the-more-i-learn-java-the-more-i-feel-that-feel-how-loose-php-is-4hi6</guid>
      <description></description>
    </item>
    <item>
      <title>the common feature of java communities is their UI sucks</title>
      <dc:creator>Aldora</dc:creator>
      <pubDate>Sat, 10 Apr 2021 07:52:33 +0000</pubDate>
      <link>https://dev.to/aldora/the-feature-of-java-community-is-their-ui-sucks-2012</link>
      <guid>https://dev.to/aldora/the-feature-of-java-community-is-their-ui-sucks-2012</guid>
      <description></description>
      <category>java</category>
    </item>
    <item>
      <title>What features to include in my java project</title>
      <dc:creator>Aldora</dc:creator>
      <pubDate>Tue, 06 Apr 2021 04:33:13 +0000</pubDate>
      <link>https://dev.to/aldora/what-features-to-include-in-my-java-project-17cd</link>
      <guid>https://dev.to/aldora/what-features-to-include-in-my-java-project-17cd</guid>
      <description>&lt;p&gt;I plan to switch from php to java, and in order to find a job as java programmer, I plan to write a project to show that I'm capable to write with java.&lt;br&gt;
My question is what kind of features I should include in the project, such as basic database operations, basic deployment?&lt;/p&gt;

</description>
      <category>java</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Use Curl to diagnose slow network</title>
      <dc:creator>Aldora</dc:creator>
      <pubDate>Fri, 16 Oct 2020 16:31:42 +0000</pubDate>
      <link>https://dev.to/aldora/use-curl-to-diagnose-slow-network-2bhp</link>
      <guid>https://dev.to/aldora/use-curl-to-diagnose-slow-network-2bhp</guid>
      <description>&lt;p&gt;article recomendation:&lt;br&gt;
&lt;a href="https://blog.cloudflare.com/a-question-of-timing/"&gt;A Question of Timing&lt;/a&gt;&lt;/p&gt;

</description>
      <category>network</category>
    </item>
    <item>
      <title>PHP Child Process and Signal-Part 2</title>
      <dc:creator>Aldora</dc:creator>
      <pubDate>Mon, 12 Oct 2020 16:51:53 +0000</pubDate>
      <link>https://dev.to/aldora/php-child-process-and-signal-part-2-m8b</link>
      <guid>https://dev.to/aldora/php-child-process-and-signal-part-2-m8b</guid>
      <description>&lt;ul&gt;
&lt;li&gt;When the signal of forked process doesn't get successful process from &lt;code&gt;pcntl_wait()&lt;/code&gt;, it would stay untils it get processed successfully. (Once gets handled, it would not work for later &lt;code&gt;pcntl_wait()&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In the &lt;a href="https://dev.to/aldora713/php-child-process-and-signal-part-1-11m2"&gt;part 1&lt;/a&gt;, I talked about what happens when we kill parent process, then kill the child. In this part, I would talk about what would happen if we kill the process in reverse order.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nb"&gt;pcntl_async_signals&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nb"&gt;pcntl_signal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;SIGTERM&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$signal&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$status&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"inside pcntl_signal&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;$pid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;pcntl_wait&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$processStatus&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;WUNTRACED&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;//    $pid = pcntl_wait($processStatus, WNOHANG);&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;pcntl_wifexited&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$processStatus&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$code&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;pcntl_wexitstatus&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$processStatus&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;print&lt;/span&gt; &lt;span class="s2"&gt;"pid &lt;/span&gt;&lt;span class="nv"&gt;$pid&lt;/span&gt;&lt;span class="s2"&gt; returned exit code: &lt;/span&gt;&lt;span class="nv"&gt;$code&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt; "&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;print&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$pid&lt;/span&gt;&lt;span class="s2"&gt; was unnaturally terminated&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt; "&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c1"&gt;//    print_r($processStatus);&lt;/span&gt;
&lt;span class="c1"&gt;//    echo "\n";&lt;/span&gt;
&lt;span class="c1"&gt;//    echo "signal: $signal\n";&lt;/span&gt;
&lt;span class="c1"&gt;//    print_r($status);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$pid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;pcntl_fork&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;$parent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;getmypid&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"parent: &lt;/span&gt;&lt;span class="nv"&gt;$parent&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="nb"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;$childPid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;getmypid&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"child pid: &lt;/span&gt;&lt;span class="nv"&gt;$childPid&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="nb"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Execute the above script, and according to the output of process pid, first use &lt;code&gt;kill&lt;/code&gt; command to kill parent process, then kill child process. The total output would be like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;parent: &amp;lt;parent pid&amp;gt;
child pid: &amp;lt;child pid&amp;gt;
inside pcntl_signal
pid -1 returned exit code: 0
inside pcntl_signal
pid &amp;lt;child pid&amp;gt; returned exit code: 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We still create two processes, one parent, one child. Kill the child, and this invokes the signal handler in the child process. However, &lt;code&gt;pcntl_wait()&lt;/code&gt; only works when it's called in parent, so it returns -1. Then, we kill the parent, this time, the &lt;code&gt;pcntl_wait()&lt;/code&gt; in parent handles the child process status info successfully. But this raises a noticeble point: the signal which can't be handled by &lt;code&gt;pcntl_wait()&lt;/code&gt; in child process stays until successfully dealed by parent process.&lt;/p&gt;

</description>
      <category>php</category>
      <category>process</category>
    </item>
    <item>
      <title>How can we build developer network?</title>
      <dc:creator>Aldora</dc:creator>
      <pubDate>Mon, 12 Oct 2020 04:48:43 +0000</pubDate>
      <link>https://dev.to/aldora/how-can-we-build-developer-network-3df0</link>
      <guid>https://dev.to/aldora/how-can-we-build-developer-network-3df0</guid>
      <description>&lt;p&gt;In addition to building up our technical skills as developers, how can we also build up our developers network besides through official work?&lt;/p&gt;

</description>
      <category>career</category>
    </item>
  </channel>
</rss>
